-
-
Save ilearnjavascript/80d82902b8a0a51927330e46d46baacc to your computer and use it in GitHub Desktop.
es8 - async await - 4.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function promise() { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { | |
console.log('1. First thing setting up second thing'); | |
resolve(); | |
}, 1000) | |
}) | |
.then(() => { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { | |
console.log('2. Second thing setting up third thing'); | |
resolve(); | |
}, 1000) | |
}) | |
}) | |
.then(() => { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { | |
console.log('3. Third thing setting up fourth thing'); | |
resolve(); | |
}, 1000) | |
}) | |
}) | |
.then(() => { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { | |
console.log('4. Fourth thing setting up fifth thing'); | |
resolve(); | |
}, 1000) | |
}) | |
}) | |
.then(() => { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { | |
console.log('5. Fifth thing'); | |
resolve(); | |
}, 1000) | |
}) | |
}) | |
.catch(error => { | |
console.log(`It's all a big mistake.`); | |
}) | |
.finally(() => { | |
console.log('End'); | |
}) | |
} | |
promise(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment