I am calling an http request using httpClient and using response Type as \'blob\' but the problem is when it goes in error block the response type remains \'blob\'.This is c
The code from SplitterAlex worked for me but I needed the error object and the status code too. Thats why I adjusted the parseErrorBlob method a little bit.
public parseErrorBlob(err: HttpErrorResponse): Observable {
const reader: FileReader = new FileReader();
const obs = new Observable((observer: any) => {
reader.onloadend = (e) => {
const messageObject = JSON.parse(reader.result as string);
observer.error({
error : {
message : messageObject.message
},
message : messageObject.message,
status : err.status
});
observer.complete();
};
});
reader.readAsText(err.error);
return obs;
}