Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Calculator

0

62
Views
Function Query.where() called with invalid data

I want to set two conditions for displaying data. But such error occurs in the browser console.

Function Query.where() called with invalid data. Unsupported field value: undefined

ts:

How to fix it?

  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();
7 months ago · Juan Pablo Isaza
1 answers
Answer question

0

Your code looks fine but as the error message text says one of your variables this.receiverId or this._cs.senderId has the value undefined and that causes the error. Just make sure not to have undefined there by putting some kind of fallback values.

 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();
7 months ago · Juan Pablo Isaza Report
Answer question
Find remote jobs