Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

485
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!