He visto muchos sitios web (que incluyen StackOverflow) sobre el mismo error con sus soluciones, pero ninguno de ellos me ha funcionado.
Sé que el error significa que ejecuté una función usando firebase antes de que se inicializara.
Aquí están las partes relevantes de mi código:
window.addPerson = addPerson; const queryString = window.location.search; const urlParams = new URLSearchParams(queryString); const userVar = urlParams.get('user') const userVarSplitted = userVar.split('#') const userVarFormatted = userVarSplitted[0] + ":" + userVarSplitted[1] // Import the functions you need from the SDKs you need import { initializeApp } from "https://www.gstatic.com/firebasejs/9.6.4/firebase-app.js"; import { getAnalytics } from "https://www.gstatic.com/firebasejs/9.6.4/firebase-analytics.js"; import { getDatabase, ref, set } from "https://www.gstatic.com/firebasejs/9.1.0/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 // For Firebase JS SDK v7.20.0 and later, measurementId is optional const firebaseConfig = { apiKey: "AIzaSyC6KGzXriv7IoQzcayPlzi-Xt_eRLgOqko", authDomain: "jerrybot-fa77f.firebaseapp.com", databaseURL: "https://jerrybot-fa77f-default-rtdb.europe-west1.firebasedatabase.app", projectId: "jerrybot-fa77f", storageBucket: "jerrybot-fa77f.appspot.com", messagingSenderId: "374262858544", appId: "1:374262858544:web:7971e56f62fab12631fef5", measurementId: "G-JQTEB5NDRE" }; // Initialize Firebase const app = initializeApp(firebaseConfig); if (app.length === 0) { console.log("no firebas app") }else{ console.log("initialized") } const analytics = getAnalytics(app); const db = getDatabase(); function addPerson() { set(ref(db, "verified/" + userVarFormatted), { name: userVarSplitted[0], discriminator: userVarSplitted[1] }); console.log("added") } Dice Initialized en la consola, lo que significa que la aplicación existe. ¿Sabes lo que está pasando?
PD: el tipo de javascript está configurado para module
¿Sabes lo que está pasando? Gracias