Getting HttpErrorResponse for get request returning byte data as response?

Viewed 29

getting HttpErrorResponse using this headers, api returning byte data as response.

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

API REQUEST returning byte data.

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

removed responseType HttpHeaders and placed it in headers object directly. It worked for me.

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