简体   繁体   中英

Realtime listener in Firestore throws type error

I am trying to attach a realtime listener in Firebase 9 for my Vue project. This is my function:

function updateProfiles() {
      
      const q = query(collection(db, "candidateprofiles"), where("useridprimary", "==", store.state.currentUserId));
      onSnapshot(q, (snapshot) => {
        let profiles = []
        snapshot.docs.forEach((doc) => {
          profiles.push({...doc.data(), id: doc.id })
        })
        console.log('success: ' + profiles)
      })
    }

It doesn't work and I get the following error:

"Uncaught (in promise) FirebaseError: Expected type 'Ac', but it was: a custom cn object"

Thanks for any help!

I solved it, i had a mix of firestore imports from firebase/firestore and firebase/firestore/lite. The latter does not work with onSnapshot

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM