Last active
July 1, 2016 02:44
-
-
Save wgottschalk-RMS/274792639a031fd51eaf418dc7ff1332 to your computer and use it in GitHub Desktop.
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
// all asynchronous methods have been promisified | |
app.post("/purchase", (req, res) => { | |
user.findOneAsync(req.body) | |
.then( userData => permissions.findAllAsync(userData) ) | |
.then( permissions => { | |
if (isAllowed(permissions)) { | |
return transaction.processAsync(userData); | |
// userData is not defined! It's not in the proper scope! | |
} | |
}) | |
.then( confirmNum => res.send("Your purchase was successful!") ) | |
.catch( err => handleError(err) ) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment