获取 HttpErrorResponse 以获取返回字节数据作为响应的请求?

Getting HttpErrorResponse for get request returning byte data as response?

使用此 headers 获取 HttpErrorResponse,api 返回字节数据作为响应。

let headers = {
      headers: new HttpHeaders({
        'Content-Type': 'application/octet-stream',
        'responseType':'arraybuffer' as 'json',
        'uid':uid
      })
    };

API 请求返回字节数据。

this.http.get(url,headers)
    .pipe(map((res)=>{
      console.log(res)  
      return res;
    }),err=>{
      console.log(err)  //getting HttpErrorResponse
      return err;
    }

删除了 responseType HttpHeaders 并将其直接放在 headers object 中。 它对我有用。

let headers = {
      headers: new HttpHeaders({
        'Content-Type': 'application/octet-stream',
        'uid':uid
      }),
      'responseType':'arraybuffer' as 'json',
    };