Estoy tratando de implementar una cuenta regresiva del lado del servidor con firebase con la función TIMESTAMP, sin embargo, a pesar de seguir la documentación proporcionada por firebase y también una publicación sobre esto hace un tiempo ( Cómo implementar un temporizador de cuenta regresiva distribuido en Firebase ), la consola sigue diciendo yo que firebase.database() no es una función:
// Import the functions you need from the SDKs you need import { initializeApp} from "https://www.gstatic.com/firebasejs/9.8.1/firebase-app.js"; import { getDatabase, ref, onValue, update, get, set} from "https://www.gstatic.com/firebasejs/9.8.1/firebase-database.js"; // TODO: Add SDKs for Firebase products that you want to use // https://firebase.google.com/docs/web/setup#available-libraries // Your web app's Firebase configuration const firebaseConfig = { apiKey: "AIzaSyDZY8ufwFMkPhzOY-dNJm9bGXqv9okoW5g", authDomain: "f1-crypto.firebaseapp.com", databaseURL: "https://f1-crypto-default-rtdb.asia-southeast1.firebasedatabase.app", projectId: "f1-crypto", storageBucket: "f1-crypto.appspot.com", messagingSenderId: "512980395232", appId: "1:512980395232:web:9d81bc5d7c58bc5a13dc85" }; // Initialize Firebase const firebase = initializeApp(firebaseConfig); const database = firebase.database(); const reff = database.ref("countdown"); reff.set({ startAt: ServerValue.TIMESTAMP, seconds: 20 }); Uncaught TypeError: firebase.database is not a functionLa documentación para esta cuenta regresiva de marca de tiempo también es bastante escasa, por lo que cualquier ayuda sería muy apreciada.
const database = getDatabase();¿Has probado esto?