Skip to content

Instantly share code, notes, and snippets.

@dm03514
Created November 8, 2015 22:59
Overview of multiple async request
/**
* 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