How to get body from HttpErrorResponse in Angular 6?

后端 未结 5 813
予麋鹿
予麋鹿 2020-12-11 17:14

I have created a REST API call in my Angular app which downloads a file.

I am setting responseType to \'blob\' since I am expecting a file in response.

But w

5条回答
  •  粉色の甜心
    2020-12-11 17:42

    Try this

    if(error.error instanceof Blob) {
        error.error.text().then(text => {
          let error_msg = (JSON.parse(text).message);
          console.log(error_msg)
        });
    } else {
        //handle regular json error - useful if you are offline
    }       
    

提交回复
热议问题