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

486
Visualizações
How to read/retrieve data from Firebase using Javascript

I am trying to get my datas from firebase with console log but i am getting an error. The error is: image This is my database: https://i.stack.imgur.com/A1zYm.png

<script type="module">
      import {
        initializeApp
      } from "https://www.gstatic.com/firebasejs/9.4.0/firebase-app.js";
      import {
        getDatabase,
        set,
        ref,
        update
      } from "https://www.gstatic.com/firebasejs/9.4.0/firebase-database.js";
      import {
        getAuth,
        createUserWithEmailAndPassword,
        signInWithEmailAndPassword,
        onAuthStateChanged,
        signOut
      } from "https://www.gstatic.com/firebasejs/9.4.0/firebase-auth.js";
      const firebaseConfig = {
        apiKey: ,
        authDomain: ,
        databaseURL: ,
        projectId: ,
        storageBucket: ,
        messagingSenderId: ,
        appId: ,
        measurementId:
      };
      const app = initializeApp(firebaseConfig);
      const db = getDatabase(app);
      const auth = getAuth();
      const firebaseRef = firebase.database().ref("Users");
      firebaseRef.once("value", function(snapshot) {
        snapshot.forEach(function(element) {
          console.log(element);
        })
      });
    </script>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You're trying to use the old v8 syntax with Firebase SDK 9, which won't work. You'll either have to use the new modular syntax, or import the older SDKs or the compatibility versions on v9.

In v9 syntax, getting a reference to and reading a value from the database is done with:

import { getDatabase, ref, get } from "firebase/database";

...

const database = getDatabase();

const firebaseRef = ref(database, "Users");
get(firebaseRef, function(snapshot) {
  snapshot.forEach(function(element) {
    console.log(element);
  })
});

For more examples, see the Web version 9 (modular) tabs in the documentation I linked above, and the upgrade guide specifically the section on upgrading with the compat libraries.

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