Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function p1(args) {
- return new Promise((resolve, reject) => {
- args.b = 10;
- // throw Error('aaaahhhhhh')
- setTimeout(() => resolve(args), 100);
- });
- }
- function p2(args) {
- args.c = 20;
- return Promise.resolve(args);
- }
- function p(args) {
- return new Promise((resolve, reject) => {
- setTimeout(() => resolve(args), 100);
- });
- }
- p({ a: 1, b: 2 })
- .then(p1)
- .then(p2)
- .then(result => console.log(result))
- .catch(error => console.log(error.message));
Add Comment
Please, Sign In to add comment