Created
July 14, 2015 07:51
example
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
function mySexyMethod() { | |
return new Promise(function (resolve, reject) { | |
someAsync.method(params, function (err, data) { | |
if (err) { | |
return reject(err); | |
} | |
resolve(data); | |
}) | |
}); | |
} | |
### Express router | |
var wrap = require('co-express'); | |
router.verb('some-route', wrap(function* (req, res, next) { | |
var val; | |
try { | |
val = yield mySexyMethod(); | |
} catch (e) { | |
return next(e); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment