I ave a server call like below
In success case,
STATUS---200
{error_code: 0, status: "success", results: [,…], message: "Album successfully found."}
In failure case, STATUS---401
Login credentials are incorrect.
I am handling the code as,
this.http.post(this.serverUrl+'login',loginForm.value,{headers: headers})
.subscribe(response => {
if (response.json().error_code === 0) {
console.log('success');
} else {
console.log('fail');
}
})
}
But here its an error (401-status).So it is not coming to the else case.Can anyone suggest help to handle or catch this error.thanks.