I'm attempting to retrieve data from a schedule collection based on a field matching the user's id. However, I'm encountering an issue with the error message: "Function Query.where() requires a valid third argument, but it was undefined."
userId;
uid;
sched: Observable<ScheduleModel[]>;
In the ngOnInit()
ngOnInit() {
this.userId = this.afAuth.authState.subscribe(user => {
this.uid = user.uid;
});
this.getSched();
}
getSched() {
this.sched = this.afs.collectionGroup<ScheduleModel>('schedule', ref => ref.where('uid', '==', this.uid)).valueChanges();
}
The issue seems to be with this.uid in the query, however:
- When I manually input the actual user uid 'iq6DkETjgMSMIdxw9cvLEzbf9Fr2' instead of using this.uid, it works.
- In my template file, {{ uid }} displays the correct id, confirming that it is not actually undefined. https://i.sstatic.net/jXOBh.png