Created
October 26, 2020 15:30
-
-
Save insanj/9c2c21272ebe449bc8ca9a3a41428c50 to your computer and use it in GitHub Desktop.
fun with promises
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 hello() { | |
return new Promise((resolve, reject) => { | |
const world = async function() { | |
return 'hello'; | |
} | |
world().then(r => | |
resolve(r) | |
).catch(e => { | |
reject(e); | |
}) | |
}); | |
} | |
hello().then(result => { | |
console.log(result); | |
}).catch(error => { | |
console.log(error) | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment