title: How to return AWS Lambda callback values with node js
body: <p>I am a bit new to AMS Lambda.</p>
  <p>I wrote a small (working) function to execute a simple sql statement on HarperDB. The lambda function works well and the logs show the resulted rows from <em>TableName</em></p>
  <p>The question is how do I fetch or return the resultant values from the execution of SQL statement.</p>
  <p>Following is my code</p>
  <pre><code>exports.handler = (event, context, callback) =&gt; {
    
    //console.log(&quot;Event is &quot;,event);
    //console.log(&quot;Context is &quot;,context);
    //console.log(&quot;callback is&quot;,callback)
    
      var https = require('follow-redirects').https;
      var fs = require('fs');
      
      console.log(context); // for analysis purpose
      
      var options = {
        'method': 'POST',
        'hostname': 'MyInstance-MyAccount.harperdbcloud.com',
        'path': '/',
        'headers': {
          'Authorization': 'Basic MyAuthoriztionCode',
          'Content-Type': 'application/json'
        },
        'maxRedirects': 20
      };
      
      var req = https.request(options, function (res) {
        var chunks = [];
      
        res.on(&quot;data&quot;, function (chunk) {
          chunks.push(chunk);
        });
      
        res.on(&quot;end&quot;, function (chunk) {
          var body = Buffer.concat(chunks);
          console.log(body.toString());
        });
      
        res.on(&quot;error&quot;, function (error) {
          console.error(error);
        });
      });
      
      var postData = JSON.stringify({
        &quot;operation&quot;: &quot;sql&quot;,
        &quot;sql&quot;: &quot;SELECT * FROM MyInstanceName.TableName&quot;
      });
      
      req.write(postData, callback);
      req.end();
      
      const response = {
          statusCode: 200,
          body: JSON.stringify('Select Completed!'),
      };
      
      return (response);  // I want to get the result of execution of my sql statement
      
      };
  </code></pre>
  <p><strong>How do I return the result of execution of the SQL statement</strong></p>