title: Stream Response into HTTP Response
body: <p>I have an API that is trying to make an HTTP request to an API that streams and image back to the me, then either stream that image back to the client making the request to me or wait until the image has been streamed to me and send it all at once.</p>
  
  <p>I am using Express and request-promise.</p>
  
  <p>Here's a shortened version of my code.</p>
  
  <pre><code>const express = require('express');
  const router = express.Router();
  const request = require('request-promise');
  
  const imgFunc = async () =&gt; {
    try {
      const response = await request.get({
        method: 'GET',
        uri: `http://localhost:8080`,
      });
      return response;
    } catch(err) {
      console.log(err);
    }
  };
  
  router.get('/', async function(req, res, next) {
    try {
      const response = await imgFunc();
      return res.send(response);
    } catch (err) {
      console.log(err);
    }
  });
  
  module.exports = router;
  </code></pre>
  
  <p>The image that I get back is just what I assume is the binary data and I don't know if I need to do something at the request-promise level to make that right or when I send it back to the client.</p>
  
  <p>The server that I have running at localhost:8080 mimics the actual server that I will be hitting when this is all said and done.</p>