When getting a 409 error from backend, I would like to display the response message that the backend developer provides me.
I do this
return this.http.post('url to API', data, {
reportProgress: true,
observe: 'events'})
.pipe(
map(
res => {
return res;
}
),
catchError((error) => {
return throwError(error);
})
);
here are my imports
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { map, catchError } from 'rxjs/operators';
import { environment } from '../../environments/environment';
import { Observable, Observer, throwError } from 'rxjs';
import { AuthService } from '../components/auth/auth.service';
but I get this in my console
typeError: _node_modules_rxjs__WEBPACK_IMPORTED_MODULE_3__.Observable.throw is not a function
at CatchSubscriber.selector (http-load.interceptor.ts:21)
at CatchSubscriber.push../node_modules/rxjs/_esm5/internal/operators/catchError.js.CatchSubscriber.error (catchError.js:43)
at MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._error (Subscriber.js:132)
at MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.error (Subscriber.js:106)
at XMLHttpRequest.onLoad (http.js:1849)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421)
at Object.onInvokeTask (core.js:4053)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:420)
at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:188)
at ZoneTask.push../node_modules/zone.js/dist/zone.js.ZoneTask.invokeTask [as invoke] (zone.js:496)