Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

123
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda