title: How to define two export handlers within one function and use variable from one handler in another one?
body: <p>I am quite new to Node JS Lamda functions and still learning.</p>
  <p>I have a function and here is the TEST working code:</p>
  <pre class="lang-js prettyprint-override"><code>const https = require(&quot;https&quot;)
  var url = &quot;https://docs.aws.amazon.com/lambda/latest/dg/welcome.html&quot;
  
  exports.handler = async (event) =&gt; {
    var variable_1 = &quot;test 1&quot;
    var variable_2 = &quot;test 2&quot;
  
    // TODO implement
    const response = {
      statusCode: 200,
      body: JSON.stringify(&quot;Hello from Lambda!&quot;) + url,
    }
  
    return response
  }
  
  </code></pre>
  <p>I need to perform two actions within the same function. Is it possible to have two export handlers like this? and how can I use variable from one handlers in another?</p>
  <pre><code>const https = require(&quot;https&quot;)
  var url = &quot;https://docs.aws.amazon.com/lambda/latest/dg/welcome.html&quot;
  
  exports.handler = async (event) =&gt; {
    var variable_1 = &quot;test 1&quot;
    var variable_2 = &quot;test 2&quot;
  
    // TODO implement
    const response = {
      statusCode: 200,
      body: JSON.stringify(&quot;Hello from Lambda!&quot;) + url,
    }
  
    return response
  }
  
  //second handler - is this possible?
  
  exports.handler = async (event) =&gt; {
    var variable_3 = variable_1 + variable_2
  
    // TODO implement
    const response2 = {
      statusCode: 200,
      body:
        JSON.stringify(&quot;Hello from Lambda - 2nd function!&quot;) + url + variable_3,
    }
  
    return response2
  }
  </code></pre>