How to read RAW JSON in Angular JS from HTTP get method, when response type is arraybuffer?

Viewed 2622

I am trying to read ByteArray to show PDF form Java into Angular JS using

 method : 'GET'
 url        : '',
 cache  : isCache||false,
 responseType: 'arraybuffer'

This is working fine when everything okay.

But when I throw an exception with some proper JSON and marking HTTP Status as bad request, I can't read JSON response even after changing config to respone.config.responseType='application/json'.

It showing only empty ArrayBuffer {} on response.data.

But important thing here is, I can see JSON response in google chrome developer tool request.

I googled, searched on stack overflow but didn't find much.

Below lines added later

I am adding response object picture and data received pic from chrome network connection.

First Image : Response object from error function of angular JS.

enter image description here

Second Image - Server returning proper JSON message

enter image description here

Third Image - Request and Response Header pics

enter image description here

Only problem I am facing is not able read data of response as I set response type to arraybuffer

2 Answers
Related