I have a Firestore database structured in a particular way, and at the moment I am focused on retrieving data from the userFavorites collection.
Looking at My Favorite Service
async getfavoriteList(): Promise<firebase.firestore.QuerySnapshot> {
const user: firebase.User = await this.authService.getUser();
if (user)
{
this.FavoriteListRef = firebase
.firestore()
.collection(`userFavorites`);
return this.FavoriteListRef.where('uid', '==', user.uid).get();
}
}
}
Regarding Favorite TS
favoriteList: any;
public favoriteListRef: firebase.firestore.CollectionReference;
this.favoriteService.getfavoriteList().then(favoriteListSnapshot => {
this.favoriteList = [];
favoriteListSnapshot.forEach(snap => {
this.favoriteList.push({
id: snap.id,
favoriteList: snap.data().favourite
});
console.log(snap.data().favourite)
return false;
});
});
}
Upon logging the data using -- console.log(snap.data().favourite), it appears correctly within the console logs.
However, when attempting to display this data within the view utilizing the provided HTML structure, there are some issues encountered. I have also attempted outputting the data using JSON pipe.
<ion-grid>
<ion-row>
<ion-col size="12" >
<ion-card *ngFor ="let favorite of favoriteList">
<div class="card-title">{{ favorite | json }}</div>
<div>{{favorite?.description}}</div>
</ion-card>
</ion-col>
</ion-row>
</ion-grid>
At this point, it seems that something is not functioning as expected. What could be causing this discrepancy?