Skip to content

Instantly share code, notes, and snippets.

@volca
Created December 5, 2012 05:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save volca/4212565 to your computer and use it in GitHub Desktop.
Save volca/4212565 to your computer and use it in GitHub Desktop.
promise for node.js
some_fun(req, res, next)
.pipe(function() { return redis.incr('next_id') })
.fail(function(e) { return next(e); })
.pipe(function() { return redis.set('key', {id:r, now:Date.now()}) })
.done(function(res) {res.send([1, 'ok'];})
.fail(function(e) {return next(e); })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment