1

I have this GET request I built to call Google APIS dot com to get an image of a house at a given address. It's all working fine. In Postman it displays the image from the body of the request. All good!

I converted the code to NodeJS REQUEST. Put that code into my project. It all works though the data returned is all �����JFIF������ like this in the BODY returned.

Can you point me to some resources or can you tell me in NODEJS how I get that into a Image type variable. I want to then display it using JSON code into Messenger Bot. I have the JSON code to send a IMAGE type back to Messenger - I just need to get the results of the GET above into a format in NODEJS that will work - like a PNG or JPG format.

This is the code I used from Postman CODE:

var options = { method: 'GET',
  url: 'https://maps.googleapis.com/maps/api/streetview',
  qs: 
   { size: '450x450',
     location: 'N108W15303%20Bel%20Aire%20Ln%2053022',
     fov: '90',
     heading: '235',
     pitch: '10',
     key: 'xxx' },
  headers: 
   { 'Postman-Token': 'xxx',
     'Cache-Control': 'no-cache',
     Accept: 'application/json' } };

requestGoogle(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

The BODY var is is all ����JFIF��C

It displays great in the Postman App. so you are somehow converting it to display it - what I am looking for.

Any help would be appreciated - or direct me to a resource that can help that would be great.

4
  • This looks like binary data being returned, i ran into this before and will look to see how I solved it. Commented Apr 2, 2018 at 22:27
  • Did you try using body inside image tag: <img src="//maps.googleapis.com/maps/api/streetview?size=600x300&amp;location=eiffel%20tower,%20paris,%20france&amp;heading=-45&amp;pitch=42&amp;fov=110" border="1px"> Refer developers.google.com/maps/documentation/javascript/streetview or developers.google.com/maps/documentation/streetview Commented Apr 3, 2018 at 0:46
  • I have not since this is not being served up for display. Using nodejs to get image and then display inside Messenger. Commented Apr 3, 2018 at 2:29
  • 2
    Just found this - this is exactly what I am getting back as far as the weird characters. It says here it's returning a JPG which makes sense. If you were to put the URL in browser you get back a streetview.jpg. stackoverflow.com/questions/30575008/… Commented Apr 3, 2018 at 2:33

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.