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

122
Visualizações
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 Respostas
Responde à pergunta

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 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