Angular 6 using HttpClient. No interceptors implemented for now.
I have an admin service where I'm doing a http call to MSGraph. In this case I'm getting an error 400 bad request which I'm sending to the notification handler.
I've slided in that console.log to make sure that the error block is firing at all and another cnosole.log to see if the 'data' getting back from the server is an error.
None of the console.logs fire yet the global error handler still displays the 400 bad request response in the console.
I'd like to be able to use this response and display a user-friendly message.
Code:
this.http.get(this.GRAPH_ROOT_URL + this.APP_ID, { headers }).subscribe(data => {
this.notification.done(data);
console.log(data);
}), error => {
this.notification.error(`Error getting users from Microsoft GRAPH API. Reason: ${error}`)
console.log("this is observable error", error);
}
() => console.log('Completed')
. Subscribe function takes 3 params - success, error and complete, these are all callbacks so you pass some function there, just like the functions you pass for success and error. My idea was that the complete callback was called. – Pulsate