I'm using angular to make a http.get
request to retrieve an image I have stored on the backend. Problem is once I get it, I don't know how to display it. Here's my code:
Node:
getImage = function(req, res){
res.setHeader('Content-Type', req.query.mimetype)
fs.createReadStream(path.join('./uploads/', req.query.filename)).pipe(res)
}
Angular
$http.get("/getImage/", {params: {"filename" : $scope.recipe.image.filename, "mimetype" : $scope.recipe.image.mimetype}})
.then(function(returnData){
$scope.image = returnData.data;
})
HTML:
<img ng-src="{{image}}">
I've used console.log
to attempt to display what is coming back, and this is what I get:
I'm guessing that's the image, but again, I don't know how to properly display it. Any tips?