+ const url = `${this.heroesUrl}/${id}`;
+ return this.http.get<Hero>(url).pipe(
+ tap(_ => this.log(`fetched hero id=${id}`)),
+ catchError(this.handleError<Hero>(`getHero id=${id}`))
+ );
+ }
+
+ /** PUT: update the hero on the server */
+ updateHero(hero: Hero): Observable<any> {
+ return this.http.put(this.heroesUrl, hero, this.httpOptions).pipe(
+ tap(_ => this.log(`updated hero id=${hero.id}`)),
+ catchError(this.handleError<any>('updateHero'))
+ );