Quiero establecer dos condiciones para mostrar datos. Pero tal error ocurre en la consola del navegador.
Function Query.where() called with invalid data. Unsupported field value: undefined
t:
¿Como arreglarlo?
this.itemsCollection = this.afs.collection<Message>('messages', ref => { let query: firebase.default.firestore.CollectionReference | firebase.default.firestore.Query = ref; query = query.where('receiverId', '==', this.receiverId); query = query.where('senderId', '==', this._cs.senderId); return query; }); this.items = this.itemsCollection.valueChanges();
Su código se ve bien, pero como dice el texto del mensaje de error, una de sus variables this.receiverId
o this._cs.senderId
tiene el valor undefined
y eso causa el error. Solo asegúrese de no tener undefined
allí poniendo algún tipo de valores alternativos.
this.itemsCollection = this.afs.collection<Message>('messages', ref => { let query: firebase.default.firestore.CollectionReference | firebase.default.firestore.Query = ref; query = query.where('receiverId', '==', this.receiverId || ''); query = query.where('senderId', '==', this._cs.senderId || ''); return query; }); this.items = this.itemsCollection.valueChanges();