Created
November 8, 2015 22:59
Overview of multiple async request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Aggregates results from the API calls | |
*/ | |
function aggregateResults(results) {} | |
app.get('/endpoint', function(req, res) { | |
var apiUrls = [ | |
'http://api/endpoint1', | |
'http://api/endpoint2', | |
'http://api/endpoint3', | |
]; | |
var results = []; | |
// make requests to all apiUrls and save result of each call in `results` | |
// ?????????????????? | |
// do something with all the results | |
var aggregatedResults = aggregateResults(results); | |
// send processed results to client | |
res.send(aggregatedResults); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment