title: Asynchronous HTTP request in AWS Lambda
body: <p>I am wanting to execute a http request inside of a lambda function, invoked by API Gateway. The problem is, the request takes a bit of time to complete (&lt;20 seconds) and don't want the client waiting for a response. In my research on asynchronous requests, I learned that I can pass the <code>X-Amz-Invocation-Type:Event</code> header to make the request execute asynchronously, however this isn't working and the code still "waits" for the http request to complete. </p>
  
  <p>Below is my lambda code: </p>
  
  <pre><code>'use strict';
  
  const https = require('https');
  
  exports.handler = function (event, context, callback) {
      let requestUrl;
      requestUrl = event.queryStringParameters.url;
  
      https.get(requestUrl, (res) =&gt; {
          console.log('statusCode:', res.statusCode);
          console.log('headers:', res.headers);
  
          res.on('data', (d) =&gt; {
              process.stdout.write(d);
          });
      }).on('error', (e) =&gt; {
          console.error(e);
      });
  
      let response = {
          "statusCode": 200,
          "body": JSON.stringify(event.queryStringParameters)
      };
      callback(null, response);
  };
  </code></pre>
  
  <p>Any help would be appreciated.</p>