nuxt-community / firebase-module

🔥 Easily integrate Firebase into your Nuxt project. 🔥
https://firebase.nuxtjs.org
MIT License
641 stars 99 forks source link

SSR: Error in fetch(): Function Query.where() called with invalid data #535

Closed portikM closed 3 years ago

portikM commented 3 years ago

Description

I am trying to fetch some data in fetch() hook:

async fetch() {
    const postSnapshot = await this.$fire.firestore
      .collection('posts')
      .where('slug', '==', this.$route.params.slug)
      .limit(1)
      .get()

      // some more code here
}      

But getting an error: Error in fetch(): Error [FirebaseError]: Function Query.where() called with invalid data. Unsupported field value: undefined

Can't be an issue with the route parameter as the slug is there when I try to console it.

Could be related to https://github.com/nuxt-community/firebase-module/issues/167

The solution proposed here did not work: https://firebase.nuxtjs.org/community/faq/#firestore-using-array-contains-or-array-contains-any-does-not-work

portikM commented 3 years ago

Sorry, my bad, closing this as it turned out to be an error coming from a different fetch() hook inside one of the components where the parameter passed to .where() clause was indeed undefined.

Would be helpful if error message in the console mentioned which fetch() hook is failing though, took me a while to figure out that I'm looking at the wrong block of code.

Cheers!