Attempts to retrieve the user's photoUrl based on their ID have been unsuccessful. Here is a snapshot of my firestore collection, can someone please guide me on how to access the photoUrl? https://i.stack.imgur.com/p2Zvm.jpg The main collection is 'User', with documents identified by unique IDs containing various fields including the photoUrl that I am trying to access.
getImage(id) { this.users=this.db.collection('user').doc(id).collection('photurl').valueChanges(); console.log(this.users); }
I implemented the above code but encountered a new issue - the function calls itself continuously and the picture does not display as expected.
<div *ngFor="let Question of Questions "> <img src="{{ getImage(Question.authorNo) }}" class="d-block ui-w-40 rounded-circle" alt="">
This HTML snippet uses an iterator since there are multiple questions. It retrieves the authorID, matches it with the userID, and displays the corresponding photoUrl if a match is found. Below is the function responsible for getting the photoUrl:
getImage(id) { this.db.doc(
user/${id}`).valueChanges().subscribe(user => {
this.user = user;
this.url = this.user.photoUrl;
//console.log(this.url);
}); return this.url; }