Skip to content

Instantly share code, notes, and snippets.

@evanshortiss
Last active June 9, 2016 15:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evanshortiss/d240ca01fe0eba5f6aa4624a7c74f510 to your computer and use it in GitHub Desktop.
Save evanshortiss/d240ca01fe0eba5f6aa4624a7c74f510 to your computer and use it in GitHub Desktop.
'use strict';
var express = require('express')
, async = require('async');
var app = express();
function getAges (callback) {
callback(null, ['23', '43']);
}
function getUsers (callback) {
callback(null, ['jane', 'john']);
}
function getData (callback) {
async.parallel({
ages: getAges,
users: getUsers
}, callback);
}
app.get('/', function (req, res, next) {
function onData (err, data) {
if (err) {
res.status(500).json({
msg: 'error'
});
} else {
res.json(data);
}
}
getData(onData);
});
app.listen(3001, function (err) {
if (err) {
throw err;
}
console.log('listening on 3001');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment