doc: create rejecting a pizza section
This commit is contained in:
1 parent
b813585148
commit
6f4e690e79
1 file changed
+15
@@ -224,3 +224,18 @@ let orderPizza = new Promise(orderExecutor);
|
|||||||
orderPizza.then(function (value) { console.log(value); });
|
orderPizza.then(function (value) { console.log(value); });
|
||||||
console.log("Waiting for my pizza!");
|
console.log("Waiting for my pizza!");
|
||||||
```
|
```
|
||||||
|
|
||||||
|
# 拒绝一个披萨
|
||||||
|
```javascript
|
||||||
|
function orderExecutor(resolve, reject) {
|
||||||
|
console.log('Pizza ordered...');
|
||||||
|
setTimeout(function() {
|
||||||
|
reject("Ran out of cheese. Can you believe it?");
|
||||||
|
}, 2000)
|
||||||
|
}
|
||||||
|
|
||||||
|
let orderPizza = new Promise(orderExecutor);
|
||||||
|
orderPizza
|
||||||
|
.then(function () { console.log("Woohoo, let's eat!"); })
|
||||||
|
.catch(function (value) { console.log(value); });
|
||||||
|
```
|
||||||
Reference in new issue
Block a user