HTTP
import { HttpClient, HttpHeaders } from '@angular/common/http';return this.http.get<Hero[]>('api/heroes');const httpOptions = {
headers: new HttpHeaders({ 'Content-Type': 'application/json' })
};
this.http.put(this.heroesUrl, hero, this.httpOptions)Error Handling
import { catchError, map, tap } from 'rxjs/operators';
return this.http.get<Hero[]>(this.heroesUrl)
.pipe(
catchError(this.handleError('getHeroes', []))
);Last updated