title: Synchronized multiple API calls
body: <p>I need to fetch the data from two different API endpoints, and after both data is fetched I should do something with those data (ie. compare the data from two sources).</p>
  
  <p>I know how to fetch the data from one API, and then call the callback function to do something with the data. I am doing this as follows.</p>
  
  <pre><code>function getJSON(options, cb) {
     http.request(options, function(res){
         var body = "";
  
         res.on("data", function(chunk){
            body += chunk;
        });
  
         res.on("end", function(){
            var result = JSON.parse(body);
            cb(null, result);
        });
  
         res.on("error", cb);
     })
     .on("error", cb)
     .end();
  }
  
  var options = {
      host: "api.mydata1.org",
      port: 8080,
      path: "/data/users/3",
      method: "GET"
  }
  
  getJSON(options, function(err, result) {
      if (err) {
          return console.log("Error getting response: ", err);
      }
  
      // do something with the data
  
  });
  </code></pre>
  
  <p>Now, what I would want to have something like:</p>
  
  <pre><code>var options2 = {
          host: "api.mydata2.org",
          port: 8080,
          path: "/otherdata/users/3",
          method: "GET"
      }
  </code></pre>
  
  <p>Those would be the options to connect to the other API, and have a single callback function that would get called whenever the data from <strong>both</strong> APIs is loaded. How can I do that?</p>