0

I want to get header http when i have an error in my call of api

this.http.get('/monapi',{responseType: 'blob', observe: 'response' })
.subscribe( (res) => 
{ 
    // I have http-header here in object res debugger; 
    console.log(res); 
}, 
(error) => { 
    // But here, i have no http header :(
    debugger; 
    console.log(error); 
} );

I do not see how to do it :(

Thanks for your help

2
  • Out of curiosity, why do you need http-header in error? Commented Sep 16, 2019 at 8:45
  • Because, the api send message in header when a error occured Commented Sep 16, 2019 at 9:08

1 Answer 1

2

You can get it that way error.headers, HttpErrorResponse have headers property:

(error: HttpErrorResponse) => { 
  debugger; 
  console.log(error.headers); 
}
Sign up to request clarification or add additional context in comments.

1 Comment

I've already try this solution, but i found the problem. I have an interceptor that delete the header. Now it's work. Thanks a lot

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.