user173092
user173092

Reputation: 129

@angular/http to @angular/common/http

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

Answers (1)

akotech
akotech

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

Related Questions