title: How to send image to client using Express/Node.js?
body: <p>I am writing a simple Express API integrating with Google Places API, and trying to send the place photo down to the client, but can't get it to work. The response from the Google Places API looks something like this:</p>
  
  <p><img src="https://i.stack.imgur.com/3rXdf.png" alt="enter image description here"></p>
  
  <p>The response object also contains a <code>headers</code> property. I've tried sending the image back like this:</p>
  
  <pre><code> router.get('/photo/:photoRef', function (req, res) {
  
    var params = {
      maxwidth: 400,
      photoreference: req.params.photoRef,
      key: key
    };
  
    var url = baseUrl + 'photo?' + querystring.stringify(params);
  
    request(url, function (error, response, body) {
      if (!error &amp;&amp; response.statusCode == 200) {
        res.type(response.headers['content-type']);
        res.send(response.body);
      }
    });
  
  });
  </code></pre>
  
  <p>but that doesn't seem to work. I get the following image:</p>
  
  <p><img src="https://i.stack.imgur.com/QLjLu.png" alt="enter image description here"></p>
  
  <p>Any help would be greatly appreciated.</p>