My API (.Net Core) returns a correlation id header with each response. This is handled at the start and end of the pipeline to uniquely identify each interaction with the API. This will happen if my application throws an exception resulting in a HTTP 500 error.
Sample from .Net Core API logs
2017-08-27 18:40:11.1836|Microsoft.AspNetCore.Hosting.Internal.WebHost|INFO|1212dcbb-b2dc-46dd-a66f-2fa3c3c76f13|Request finished in 3526.1966ms 500 |
The GUID in the output is the correlation id, and you can see the final response code of 500 at the end of the formatted message.
Angular Typescript Code
The code in my Angular application is pretty simple...
return this.http.post(
uri,
body)
.map(response => {
// TODO: Handle responses
})
.catch((error:any) => {
// TODO: Handle errors
});
However, in the event the server returns a 500 error, investigation of the error
object yields a headers
object which is empty giving me no access to any headers returned from the server.
I can see in the Chrome developer tools that the header is present on the response.
Is there a way I can get access to these headers in the event of an error condition?