I am writing a simple wrapper in node.js which calls Goole Places API and gets a photo using photo_reference. When I run this and process the request from Postman it works but does not display photo itself. In the code below mapsClient.placesPhoto does return a huge response with many tags. Its not just raw image data. My question is how do I extract image or image data from googleResp object and send it back to client?
var googleMapsClient = require('@google/maps').createClient({
key: 'xyz'
});
app.post('/getGooglePlacePhoto/:photoref', function(req, res){
googleMapsClient.placesPhoto({
photoreference: req.params["photoref"],
maxwidth: 70,
maxheight: 70
}, function(err, googleResp){
if (!err) {
debug('got response from google');
res.set('Content-Type','image/jpeg');
debug(googleResp.body);
res.send(200, googleResp.body);
} else {
debug(err);
res.send(409, err);
return;
}
});
});