title: Get image from external web service and pass it to another express js route
body: <p>I have a external web service, which returns image.</p>
  
  <p>and I have node express route which call that external web service.</p>
  
  <p>I am struggling to pass the returned object of external web service (which is image) as express route's  return object</p>
  
  <p>here is this example, I am trying to get image from external URL and passing it as it is.. it doesn't work, can someone help me know to do so?</p>
  
  <pre><code>exports.getImage = function (req, res) {
  
      var http = require('http');
  
  
      var options = {
          host: 'http://www.gettyimages.co.uk',
          path: '/CMS/StaticContent/1391099215267_hero2.jpg',
          method: 'GET',
          headers: {
              "content-type": "image/jpeg"
          }
      };
  
      var request = http.request(options, function(response) {
          var imagedata = '';
          response.setEncoding('binary');
  
          response.on('data', function(chunk){
              imagedata += chunk
          });
  
          response.on('end', function() {
              console.log('imagedata: ', imagedata);
              res.writeHead(200, {'Content-Type': 'image/jpeg' });
              res.send(imagedata);
          });
      }).on("error", function(e) {
          console.log("Got error: " + e.message, e);
      });
  
      request.end();
  
  };
  </code></pre>