1function promise1 () { 2 let p = new Promise((resolve) => { 3 console.log('promise1'); 4 resolve('1') 5 }) 6 return p; 7} 8function promise2 () { 9 return new Promise((resolve, reject) => { 10 reject('error') 11 }) 12} 13promise1() 14 .then(res => console.log(res)) 15 .catch(err => console.log(err)) 16 .finally(() => console.log('finally1')) 17 18promise2() 19 .then(res => console.log(res)) 20 .catch(err => console.log(err)) 21 .finally(() => console.log('finally2')) 22