Using angular fire, I am fetching data from firestore based on the logged-in user. After ensuring that the user object has been retrieved, I have a command to monitor changes in the document.
async fetchUserCards() {
let _user: UserModel = await this.authService.retrieveUser();
if (_user) {
return this.angularFirestore
.collection<Card>('cards', (ref) =>
ref.where('owner', '==', _user?.uid)
)
.valueChanges();
} else {
}
}
As there is an If check for the user, the function's signature becomes Promise<Observable<board[]> | undefined>. How can I eliminate the need for 'undefined' (what should I do in the else block)?