});
});
- describe('#getHero', () => {
+ describe('#getHero', () => {
it('should return an empty observable for an invalid id', () => {
export class HeroService {
heroesUrl = 'api/heroes'; // URL to web api
+ httpOptions = {
+ headers: new HttpHeaders({ 'Content-Type': 'application/json' })
+ };
constructor(
private http: HttpClient,
);
}
+ /** 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'))
+ );
+ }
+
/**
* Handle Http operation that failed.
* Let the app continue.