title: Await function to finish calling another API
body: <p>I am new to using async/await and having a couple issues.</p>
  
  <p>I have the code below, which seems to not wait until the previous function is finished?</p>
  
  <pre><code>var url = require('url');
  var path = require('path');
  var https = require('https');
  var request = require('request');
  var url1 = 
  var url2 = 
  var url3 =
  
  
  module.exports = async function (context, req) {
      var call = await callUrl(context, url1);
      context.log(call);
      var call2 = await callUrl(context, url2);
      context.log(call2);
      var call3 = await callUrl(context, url3);
      context.log(call3);
  };
  
  function callUrl (context, web) {
      var requestUrl = url.parse(web);
      const requestOptions = {
          hostname: requestUrl.hostname,
          path: requestUrl.path,
          method: 'POST',
          headers: {
              'Content-Type': 'application/json'
          }
      };
      var request = https.request(requestOptions, function(res) {
          var data = "";
          res.on('data', function (chunk) {
              data += chunk;
          });
          res.on('end', function () {
              var jsonData = JSON.parse(data);
              return jsonData;
          });        
      }).on('error', function(error) {
          context.log("request error:", error);
          return context.done();
      });
      request.end();
  }
  </code></pre>
  
  <p>I am trying to get <code>call</code> to happen, then when it is finished <code>call2</code>, then when that is finished <code>call3</code>.</p>
  
  <p>Can someone pinpoint why this does not occur? Currently, it hits all 3 pretty much asap, and each <code>context.log</code> is <code>undefined</code> presumably because the endpoints don't return anything. Each <code>url</code> is another azure function app API I have created.</p>
  
  <p>There is nothing I am requiring to return from each <code>call</code> to use, I simply want them to finish before moving on the the next function.</p>