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

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

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