Nuxt 3 + Vuefire. Getting notifications list from remote url

76 Views Asked by At

I am using Nuxt 3 + Vuefire.

Can I get real-time data from any API (e.g.: my-site.com/api/v1/NotificationList/), or must I use Firestore? Mobile Flutter used Firebase for notification. Now I need to implement this functionality for the Web app. This is my config:

...
vuefire: {
    emulators: {
     auth: {
        options: {
          disableWarnings: true,
        },
      },
    },
    auth: {
      enabled: false,
      sessionCookie: false,
    },

    config: {
      apiKey: apiKey, // I just replaced with mock data. In my code I used the configuration from Firebase
      authDomain: 'project.firebaseapp.com',
      projectId: 'project',
      storageBucket: 'project.appspot.com',
      messagingSenderId: messagingSenderId,
      appId: appId,
      measurementId: measurementId,
    },
  },
...

I've tried this way but I get an empty array from notificationsList:

import {
  useDatabase,
  useDatabaseList,
} from 'vuefire'

import {
  ref as dbRef,
} from 'firebase/database'

const db = useDatabase()
const notificationsRef = dbRef(
  db,
  'notification/api/v1/Notification/?limit=12&offset=0&notification__source=1'
)
const { data: notificationList, pending } = useDatabaseList(notificationsRef)

and the pending is still true.

Also, I got this error:

Firebase error. Please ensure that you have the URL of your Firebase Realtime Database instance configured correctly

The URL was: https://project-default-rtdb.firebaseio.com/.lp?start=t&ser=6563956&cb=1&v=5&p=1:...

0

There are 0 best solutions below