Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

206
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda