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

121
Views
how can i read firebase realtime database?

here's my code, it is the exact copy of the docs but it says that ref.on is not a function. maybe i forgot to put a module in the import but i couldn't find any information about that.

function readpixels() {
  const db = getDatabase();
  const ref = ref(db, 'pixels');
  ref.on('value', (pixel) => {
    console.log("read")
  })
}

and here are the import lines:

import { initializeApp } from "firebase/app";
import { getDatabase, ref, push, set } from "firebase/database";
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You're importing the new v9 functions, but in your code you are then trying to use the older syntax. You'll have to pick one or the other.

In v9 syntax, the ref.on("value" would be:

import { onValue } from "firebase/database";
...
onValue(ref, (pixel) => {
  console.log("read")
}

Also see the Firebase documentation on reading from the Realtime Database with the v9 SDK.

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!