title: how to make a node http request pause execution until complete
body: <p>I'm getting a JSON response from a service that I want to pass on to another function.  When I put a breakpoint on the <code>var parsedData...</code> line and one on the <code>return resp</code>, the parsedData line gets hit first.  How can I "wait" for the request to finish before moving on in the code?</p>
  
  <pre><code>var data = sendRequest(options);
  var parsedData = parseData(commits);
  
  var sendRequest = function (options) {
      var resp = {}
      var request = https.request(options, function (response) {
          var body = '';
          response.on("data", function (chunk) {
              body += chunk.toString('utf8');
          });
  
          response.on("error", function(e){
              console.log(e);
          })
  
          response.on("end", function () {
              resp = JSON.parse(body);
              return resp;
          });
      });
      request.end();
  }
  </code></pre>