简体   繁体   English

Firestore 中的实时侦听器抛出类型错误

[英]Realtime listener in Firestore throws type error

I am trying to attach a realtime listener in Firebase 9 for my Vue project.我正在尝试在 Firebase 9 中为我的 Vue 项目附加一个实时监听器。 This is my function:这是我的 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" “未捕获(承诺)FirebaseError:预期类型为‘Ac’,但它是:自定义 cn 对象”

Thanks for any help!谢谢你的帮助!

I solved it, i had a mix of firestore imports from firebase/firestore and firebase/firestore/lite.我解决了它,我混合了从 firebase/firestore 和 firebase/firestore/lite 导入的 firestore。 The latter does not work with onSnapshot后者不适用于 onSnapshot

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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