title: Passing HTML data from AWS Lambda and API Gateway using AWS-Express
body: <p>I have a use case where when a user hits my API gateway I spawn a Lambda. The Lambda is using aws serverless express.</p>
  
  <p>The Lambda has the responsibility to fetch the data from a url. Lets say this url is <a href="http://a.co/d/dBpaoQo" rel="nofollow noreferrer">tiny url</a> which is amazons url.</p>
  
  <p>I am fetching the data. My code to fetch the data is</p>
  
  <pre><code>function (req, res) {
      var request1 = require('request')
      res.setHeader('Content-Type', 'text/html; charset=utf-8');
      request1.get('http://a.co/d/dBpaoQo')
          .on('response', response =&gt; {
              response.pipe(res);
          });
  
  }
  </code></pre>
  
  <p>However, when I see the data at the client end, I see the data as</p>
  
  <p>��P_k�0}ϧH}� U�e輹{X�`����
  ���1�\��bbmQ��]���p����CZ/��^w�q�F�����C�Ν�gy���I�����!�h�&lt;T��s0�W����r��ko7���j�ȓ�ΊyF&lt;��&lt;��z�hp+�L�&amp;�s%:|
  F�l/f٫.��*���z�2����0���JGD��8A��W��1�=�S��3����˜m.�Do~޼�|s{����O�����G���-2;O�h�;^�����4�$�D?&amp;���F֊�w����Џ~�\�P��0,Z�7´�Z
  ��s��g�\��c��ڿ�N�M���>�^�,Ka?��,�'nd�H�Z]�����\���@s��2������#�
  ra#N&lt;��V�</p>
  
  <p>(Not Pasting the whole content).</p>
  
  <p>If I run the server locally it shows the data in correct format. It is basically API gateway which is messing up with the data. I even applied </p>
  
  <pre><code>res.setHeader('Content-Type', 'text/html; charset=utf-8')
  </code></pre>
  
  <p>in my code as suggested on <a href="https://stackoverflow.com/questions/33614198/return-html-from-aws-api-gateway">stackoverflowlink</a></p>
  
  <p>Can anyone point me what am I doing wrong.</p>