Created
July 14, 2015 07:51
-
-
Save swarajgiri/16202e32aa4d80d45c62 to your computer and use it in GitHub Desktop.
example
This file contains hidden or 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