I have a setup on the backend where I fetch users info from one endpoint and their profile photos from another one.
I need to first fetch users and then their photos before displaying anything on the screen.
I've got a following interface
interface User {
id: string;
name: string;
email: string;
photoUrl?: string;
}
and two functions that return observables: getUsers and getUserPhoto.
I make the call like so:
this.getUsers().pipe(
map((users: User[]) => {
return users.forEach(user => {
// this part is problematic as I don't know how to call it properly
return this.getUserPhoto(user.id)
})
})
);
Ideally, the end result of this call should be a User array with all properties including photoUrl.