I am currently making a call to my api which returns an image as an image/jpeg
. My issue is the when calling the url through javascript angular .factory
resource I am getting my array buffer as empty {}
. Also, the bytes length is 0. If I make the call to the api url with response type '' or 'text' I do see value of multiple types. What am I missing here? Thank you for your help!
JS:
.factory("Img", function($resource) {
return $resource("http://mypathTo/image/:id", {
id: "@id"
}, {
responseType: '' //arraybuffer return empty
});
});
app.controller //code
$scope.getImage = function(productid) {
console.log(productid);
par = {id: [productid]};
Img.getImage(par).$promise.then(
function(data){
console.log("success:" + data); //I am able to see bytes when coming back as text but not with arraybuffer as data.bytelength = 0
scope.productionPicturePath = data;
return data;
},
function(data){
console.log("error" + data);
}
);
}
}