Skip to content

Instantly share code, notes, and snippets.

@conanak99
Created June 22, 2016 22:56
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 conanak99/94dccdd66207c9ea21b34e4461d15516 to your computer and use it in GitHub Desktop.
Save conanak99/94dccdd66207c9ea21b34e4461d15516 to your computer and use it in GitHub Desktop.
// Khi một function bị lỗi, promise bị reject (thất hứa)
function chở_gái_vào_hotel() {
return Promise((response, reject) => {
reject("Xin lỗi hôm nay em đèn đỏ");
});
}
xin_mẹ_mua_xe
.then(chở_gái_đi_chơi)
.then(chở_gái_vào_hotel)
.then(function() { /*Làm gì đó, ai biết*/ })
.catch(function(err) {
console.log(err); //"Xin lỗi hôm nay em đèn đỏ"
console.log("xui vl");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment