Reputation: 129
Currently I'm switching from http (@angular/http) to HttpClient (@angular/common/http) and have problems mapping my response to objects.
Old Code
getSummary(filters: IFilterParams): Observable<ISummary> {
return this.http.post('./api/test', filters).pipe(map((response: Response) => response.json()));
}
What should it be now?
Upvotes: 0
Views: 257
Reputation: 2284
If the response body is a json, you just need to remove the mapping.
getSummary(filters: IFilterParams): Observable<ISummary> {
return this.http.post<ISummary>('./api/test', filters);
}
Cheers
Upvotes: 0