I'm struggling to capture a HTTP response code correctly. In my test scenario I am uploading an image that is too large for my nginx configuration and it is throwing a 413 Http response but I cannot capture it using the following code:
... this.http.post( this.url, body, options )
.map( res => {
res.json().data;
})
.catch( ( error: Response ) => {
if (error.status === 413)
{
return Observable.throw('Asset to large');
}
else
{
console.log( error );
return Observable.throw( error.json().error || 'Server error' );
}
});
.cache();
The output of the console log which it hits is always:
Response
body:ProgressEvent
headers:Headers
ok:false
status:0
statusText:""
type:3
url:null
Can anybody please advise?