Currently, I am getting the user details in the response from the server. From that response, I want to encode the image and wants it to display on my front end. currently, this what I am doing:
HTML:   <img ng-src=data:image/png;base64,{{user_image}}>
Angularjs:
  $http({
  method: 'GET',
  url: 'userimage',
  }).then(function(response) {
     $scope.user_image = response.data;
     var str = _arrayBufferToBase64(response.data.user_image);
  }, function(response) {
    console.error('error.');
});
function _arrayBufferToBase64(buffer) {
var binary = '';
var bytes = new Uint8Array(buffer);
var len = bytes.byteLength;
for (var i = 0; i < len; i++) {
  binary += String.fromCharCode(bytes[i]);
}
return window.btoa(binary);
}
In response, I am getting user details but I don't know how to encode the image. Please let me know where I am going wrong.