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

392
Visualizações
why i can't connect javascript with firebase?

I tried to connect my javascript app with firebase, I created an account in firebase, I pasted my configuration, but it gives me 3 errors:

Unexpected token 'export';

Cannot use import statement outside a module;

firebase is not defined

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <script src="https://www.gstatic.com/firebasejs/9.8.3/firebase-app.js"></script>
    <script src="https://www.gstatic.com/firebasejs/9.8.3/firebase-firestore.js"></script>

    <script type="module">
        // Import the functions you need from the SDKs you need
        import { initializeApp } from "https://www.gstatic.com/firebasejs/9.8.3/firebase-app.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: "<key>",
          authDomain: "javascript-3bbaa.firebaseapp.com",
          projectId: "javascript-3bbaa",
          storageBucket: "javascript-3bbaa.appspot.com",
          messagingSenderId: "<id>",
          appId: "<appId>"
        };
      
        // Initialize Firebase
        const firebase = initializeApp(firebaseConfig);
        const db = firebase.firestore();
      </script>
    
</body>
</html>

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

In firebase v9, you have to use getFirestore method. Try this:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

<script type="module">

    import { initializeApp } from 'https://www.gstatic.com/firebasejs/9.8.3/firebase-app.js';
    import { getFirestore, collection, getDocs } from 'https://www.gstatic.com/firebasejs/9.8.3/firebase-firestore-lite.js';
    
    const firebaseConfig = {
        apiKey: "<key>",
        authDomain: "javascript-3bbaa.firebaseapp.com",
        projectId: "javascript-3bbaa",
        storageBucket: "javascript-3bbaa.appspot.com",
        messagingSenderId: "<id>",
        appId: "<appId>"
    };

    // Initialize Firebase
    const app = initializeApp(firebaseConfig);
    const db = getFirestore(app);
</script>

</body>
</html>

about 4 years ago · Juan Pablo Isaza Relatório
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