From: Kai Moritz Date: Sat, 16 May 2020 11:22:28 +0000 (+0200) Subject: 6: Get Data from a Server X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=a74bb0fa3f25f033319a4987bbec1acdc548f3dc;p=examples%2Fangular-tour-of-heroes 6: Get Data from a Server f) Heroes and HTTP - Tap into the Observable --- diff --git a/src/app/hero.service.ts b/src/app/hero.service.ts index 90fa42c..f8374b1 100644 --- a/src/app/hero.service.ts +++ b/src/app/hero.service.ts @@ -4,7 +4,7 @@ import { Hero } from './hero'; import { HEROES } from './mock-heroes'; import { HttpClient, HttpHeaders } from '@angular/common/http'; import { MessageService } from './message.service'; -import { catchError } from 'rxjs/operators'; +import { catchError, tap } from 'rxjs/operators'; @Injectable({ @@ -23,6 +23,7 @@ export class HeroService { return this.http .get(this.heroesUrl) .pipe( + tap((heroes: Hero[]) => this.log(`fetched ${heroes.length} heroes`)), catchError(this.handleError('getHeroes', [])) ); }