summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
10071c9)
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 { 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';
return this.http
.get<Hero[]>(this.heroesUrl)
.pipe(
return this.http
.get<Hero[]>(this.heroesUrl)
.pipe(
+ tap((heroes: Hero[]) => this.log(`fetched ${heroes.length} heroes`)),
catchError(this.handleError<Hero[]>('getHeroes', []))
);
}
catchError(this.handleError<Hero[]>('getHeroes', []))
);
}