Advertisement
Guest User

Untitled

a guest
Jan 16th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. getComments(mealId: number): Observable<Comment[]> {
  2. return this.http.get<Comment[]>(`${this.baseUrl}${this.mealUrl}/${mealId}/${this.commentUrl}`).pipe(
  3. map(results => results['_embedded'].comments),
  4. mergeMap(comments => comments.length
  5. ? forkJoin(
  6. comments.map(
  7. comment => forkJoin(
  8. of(comment),
  9. this.http.get<User>(`${comment._links.sender.href}`)
  10. ).pipe(
  11. map(data => { return { ...data[0], author: data[1] } })
  12. )
  13. )
  14. )
  15. : of(null)
  16. )
  17. );
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement