I am working on an Angular app in which I am making a rest call through HTTP as below:
login(email, password) {
let headers = new Headers();
headers.a
Use the catch operator
this.calcSub = this.http.post(this.constants.userUrl + "UpdateCalculation", body, { headers: headers })
.map((response: Response) => {
var result = response.json();
return result;
})
.catch(this.handleError)
.subscribe(
dro => this.dro = dro,
() => this.completeAddCalculation()
);
And handle the error like this:
private handleError(error: Response) {
console.error(error); // log to console instead
return Observable.throw(error.json().error || 'Server Error');
}