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

86
Visualizações
firebase realtime database undefined function

I'm trying to retrieve from a realtime db I started by init the app with the configuration like so

import {initializeApp} from 'firebase/app';
import {getDatabase} from 'firebase/database';
let config = {
  apiKey: 'xxxxxxxxxxxx',
  authDomain: 'xxxxxxxxxxxx',
...
};
const app = initializeApp(config);
const database = getDatabase(app);

then when I try using the database variable it crashes

  componentDidMount() {
    database
      .ref(`master/tickets`)
      .once('value', snapshot => {
        var obj = snapshot.val();
        console.log('obj :', obj);
      })
      .catch(error => {
        console.log(error);
      });
  }

I also have tried firebase.database.ref() it shows error cannot find variable firebase What I am doing wrong? It was working fine in previous builds

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The Firebase Web SDK underwent major breaking changes with the update to V9.0.0.

Please see the upgrade guide for details on how to modify older patterns to the new API.

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

/* ... */

componentDidMount() {
  get(ref(database, 'master/tickets'))
    .then(snapshot => {
      const obj = snapshot.val();
      console.log('obj :', obj);
    })
    .catch(error => {
      console.log(error);
    });
}
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