I have an angularjs function that calls the server url and gets responses. This server side returns xml response several times. sometimes returning the blog as an answer. Impossible to predict. If I set the response type to "blob" on the client side, it will display the image correctly. But I cannot handle non blob responses due to xml responses also showing as blob. I searched a lot on the Internet about converting blob to xml (an answer containing an xml response). But could not find the answer: (
If I delete the response type: "blob", it may not handle the blob response, but it cannot handle the blob response.
Is there a way to handle both types of responses in one method?
this is my angularjs code to get the answer
$http({
url: apiConstants.BASE_URL + 'login',
method: "POST",
responseType: "blob",
data: {
"Req": req
},
headers: {
'X-Username': aUser,
'X-Password': aPass,
"Content-Type": "application/xml"
},
dataType: "xml"
}).success(function(data, status) {
console.log(data);
}