Skip to content

Instantly share code, notes, and snippets.

@aaronshaf
Created December 3, 2013 17:27
Show Gist options
  • Select an option

  • Save aaronshaf/7773502 to your computer and use it in GitHub Desktop.

Select an option

Save aaronshaf/7773502 to your computer and use it in GitHub Desktop.
node sync example
// where User.find is another generator function, or is a promise
// assumes: https://github.com/visionmedia/co
function get(req, res) {
co(function *() {
var users = yield User.find(req.params);
// do stuff with users...
// do more stuff...
res.json({
users: users
});
})();
};
app.get('/users', get);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment