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

260
Views
How to access firebase realtimedb in NUXT js

We have a realtimedb in firebase that has data as follows:

enter image description here

On our nuxt page we have the following method:

async getDb () {
      const messageRef = this.$firebase.database.ref('test')
      try {
        const snapshot = await messageRef.once('value')
        alert(snapshot.val().message)
      } catch (e) {
        alert(e)
      }
    },

That is run by this in mounted like this:

mounted () {
    this.getDb()
  },

I keep getting this error:

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'database')

Am I doing something wrong? I have all of the firebase config in Nuxt.config.js and suth is working fine. I also added the realtimedb to services:

 services: {
  realtimeDb: true,
  auth: {
    ssr: true,
    // it is recommended to configure either a mutation or action but you can set both
    initialize: {
      onAuthStateChangedMutation: 'ON_AUTH_STATE_CHANGED_MUTATION'
      // onAuthStateChangedAction: 'onAuthStateChangedAction'
    }
  },

How do you actually access the data from the realtimedb so I can display the test array on my page?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You are using $firebase which is not included in this documentation. To grant access to your Realtime Database use the following:

$fire.database

or

$fireModule.database

Note:

If you are using nuxt/firebase version 6 use realtimeDb and database for version 7 in services of nuxt.config.js, see this link for more details.

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!