title: How to wait on async response in Express before responding to AJAX request?
body: <p>I am making an AJAX call to my Express server which then needs to make an async request to a database. I have tried using await/async and also making a promise with <code>.then</code>. </p>
  
  <p>The problem is, my server responds automatically after hitting the end of <code>testfunc</code> instead of waiting for the promise or the return statement. </p>
  
  <p>This results in an empty value being sent back to the client. Is there some way to get Express to wait on the promise or a return before responding to the AJAX request?</p>
  
  <p>Below is an example of what I am trying.</p>
  
  <pre><code>exports.testFunc = function(){
  
      var data = []
  
      asyncCall().then(function () {
          //Populate data array
  
          return { 'data' : data } 
      })
  }
  </code></pre>