Skip to content

Instantly share code, notes, and snippets.

@fariszacina
Last active November 4, 2015 10:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fariszacina/a79860e23bb9a6133936 to your computer and use it in GitHub Desktop.
Save fariszacina/a79860e23bb9a6133936 to your computer and use it in GitHub Desktop.
Promise pyramid of doom
export function bookApartment(req, res, next) {
booking
.create(req.booking)
.then(function(data){
notifier.sendBookingConfirmation(data)
.then(function(result){
statistics.log(data)
.then(function(result){
log.debug('booking-succeeded');
})
.catch(function(err){
next(err);
});
})
.catch(function(err){
next(err);
});
})
.then(function(){
res.send(200);
})
.catch(function(err) {
next(err);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment