The official Angular HttpClient documentation gives the following example for making a POST request to some backend server.
/** POST: add a new hero to the database */
addHero (hero: Hero): Observable<Hero> {
return this.http.post<Hero>(this.heroesUrl, hero, httpOptions)
.pipe(
catchError(this.handleError('addHero', hero))
);
}
But I'm confused as to why the Observable is returning Hero data, or data other than a success code at all for that matter on a POST request. I understand why a GET request would use a type assertion, but don't quite understand how this works.