title: Invoking an api inside a aws lambda but getting a null response
body: <p>I am trying to invoke a rest API inside an API but it is not returning anything. So I am making a simple lambda which returns a JSON but getting a null value as a response.</p>
  
  <pre><code>var https = require('https');
  var dt;
  exports.handler = async (event, context) =&gt; {
        var data = '';
  
      return new Promise((resolve, reject) =&gt; {
        var params = {
                  host: "cvwtzygw4a.execute-api.ap-south-1.amazonaws.com",
                  path: "/test/first"
                  };
  
          const req = https.request(params, (res) =&gt; {
            console.log('STATUS: ' + res.statusCode);
             res.setEncoding('utf8');
             res.o n('data', function(chunk) {
                 data += chunk;
               });
           res.on('end', function() {
            console.log("DONE");
  
            console.log(data);
             dt = JSON.parse(data);
            console.log(dt);
           });
  
  
        resolve(dt);
      });
  
      req.on('error', (e) =&gt; {
        reject(e.message);
      });
  
      // send the request
      req.write('');
      req.end();
   });
  };
  </code></pre>