How to get header when error http in Angular?

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


Solution 1:

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

(error: HttpErrorResponse) => { 
  debugger; 
  console.log(error.headers); 
}