f) Heroes and HTTP - Tap into the Observable
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({
return this.http
.get<Hero[]>(this.heroesUrl)
.pipe(
+ tap((heroes: Hero[]) => this.log(`fetched ${heroes.length} heroes`)),
catchError(this.handleError<Hero[]>('getHeroes', []))
);
}