I've written an api service which fetch a binary data from $http. The problem is I don't know how to used that data to display the image. PS: the binary data is actually an image.
This is my service api
getAvatar: function() {
return $http({
method : 'GET',
url : 'domain.com',
headers : {'Content-Type' : 'application/json'}
});
}
My controller
//get avatar
$scope.userAvatar = function() {
Api.getAvatar()
.then(function(result) {
//success
console.log(result.data); //this is the binary data
$scope.avatarImage = result.data;
}
}, function(result) {
//errors
});
};
At first I thought that result that the api will give me is a url but it turns out a binary. Do I have to convert it first?