Created
October 29, 2022 14:17
-
-
Save zibellon/1eddb6543152b2941e7b9730ce93bb2b to your computer and use it in GitHub Desktop.
example promise
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 funAsync() { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { | |
console.log('ASYNC END'); | |
// resolve() | |
reject("asdasdads"); | |
}, 3000); | |
}) | |
} | |
async function start() { | |
await funAsync().catch(e => {}); | |
console.log('1 OUT'); | |
try { | |
await funAsync(); | |
console.log('2 OUT'); | |
} catch (error) { | |
} | |
await funAsync(); | |
console.log('3 OUT'); | |
} | |
start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment