title: Troubles sending HTTP request in <b>express.js</b> app deployed on <b>AWS lambda</b> by Serverless Framework
body: <p>I always receive an error <b>Endpoint request timed out</b> when I implement various functions to communicate through an <i>HTTP-request</i> in <b>APIGateway</b>.  </p>
  
  <p>I would like to receive a <b>JSON Object</b> from a function, say B, response when I request <i>/test-communication-A</i>.</p>
  
  <p>This is the article I followed to explore how the app deploys on Lambda. </p>
  
  <p><a href="https://dev.to/adnanrahic/how-to-deploy-a-nodejs-application-to-aws-lambda-using-serverless-2nc7" rel="nofollow noreferrer">How to deploy a Node.js application to AWS Lambda using Serverless</a></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>method in function-A
  
  app.get("/test-communication-A", function (req, res) {
    request
      .get('https://{endpoint of function-B offered from AWS apiGateway}/test-communication-B')
      .on('response', resp =&gt; {
        return res.send(resp);
      })
      .on('error', err =&gt; {
        return res.send('error')
      })
  });
  module.exports.server = sls(app);</code></pre>
  </div>
  </div>
  </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>method in function-B
  
  app.get("/test-communication-B", function (req, res) {
    return res.send({ retCode: 0 });
  });</code></pre>
  </div>
  </div>
  </p>
  
  <p>Any input would be appreciated, thank you!</p>