From a74bb0fa3f25f033319a4987bbec1acdc548f3dc Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sat, 16 May 2020 13:22:28 +0200 Subject: [PATCH] 6: Get Data from a Server f) Heroes and HTTP - Tap into the Observable --- src/app/hero.service.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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', [])) ); } -- 2.20.1