Created
July 23, 2018 17:09
-
-
Save obbaeiei/99e34ca82682fd49bfd0db097559355e to your computer and use it in GitHub Desktop.
Async/Await example
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
async function main() { | |
const user = await promiseFindUser() | |
console.log('name: ', user.name) | |
} | |
function promiseFindUser() { | |
return new Promise((resolve)=>{ | |
setTimeout(()=>{ | |
const user = { | |
name: 'Thor' | |
} | |
resolve(user) | |
}, 1000) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment