-
-
Save TRex22/b3c14c7623a29c3158c27192c67e4a19 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