Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

202
Vistas
Getting error that Firebase Firestore imports are not declared even if in import statement

I'm trying to get a document from Firebase Firestore but every time I try getting it I get an error that my "onHomeLoad" function is not declared and if I put it in the console I then get either that doc() or getDoc() aren't declared. I tried everything I've found online but nothing worked.

My code:

import { initializeApp } from "https://www.gstatic.com/firebasejs/9.0.0/firebase-app.js";
import { getFirestore , getDoc , doc } from "https://www.gstatic.com/firebasejs/9.0.0/firebase-firestore.js";

const firebaseApp = initializeApp({
    apiKey: "",
    authDomain: "",
    databaseURL: "",
    projectId: "",
    storageBucket: "",
    messagingSenderId: "",
    appId: ""
});

const db = getFirestore(firebaseApp);

function onHomeLoad() {
    let siteSettingsHome = doc(db, 'siteSettings/home');
    getDocument(siteSettingsHome);
}
async function getDocument(docLocation) {
    let documentSnapshot = await getDoc(docLocation);
    if( homeSettingSnapshot.exists() ){
        let documentData = documentSnapshot.data();
        console.log(`Doc data: ${JSON.stringify( documentData )}`);
        return documentData;
    }
}

I've removed the stuff inside the initializeApp object here but it's filled correctly in my js document.

about 4 years ago · Santiago Gelvez
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda