title: How do I wait for the API response in Node JS before executing next line
body: <p>I am calling get API in node js and need to wait for response. Response it the output of Alexa Skill.</p>
  <h2>Here is the API code:</h2>
  <p>const GetReportOnEmail = function (UserID, ReportName) {</p>
  <pre><code>return new Promise(function(resolve, reject){
  
      var options = {        
          uri:'https://www.xxxxx/xx/xx',
          method : 'GET'
      };        
      request(options, function (error, response, body) {
          if (!error &amp;&amp; response.statusCode == 200) {
              res = body;
              resolve(res);
          }
          else {
              res = 'Not Found';
              reject(res);
          }            
      });       
  })  
  </code></pre>
  <p>}
  module.exports.GetReportOnEmail=GetReportOnEmail;</p>
  <hr />
  <p>This function I am calling in another js file:</p>
  <pre><code>            setTimeout(function () {
                  GetReportEmail.GetReportOnEmail('userID', 'ReportName').then((resp) =&gt; {
                      speechText = resp;
                  }).catch((error) =&gt; {
                      speechText = &quot;some error occurred&quot;;
                  })
              }, 20000);
  </code></pre>
  <p>-----Further lines of code-------</p>
  <p>I need to wait for the response from this API before executing next line of code. How do I do That.
  Regards,
  Naveen</p>