Skip to content

Instantly share code, notes, and snippets.

@obbaeiei
Created July 23, 2018 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save obbaeiei/99e34ca82682fd49bfd0db097559355e to your computer and use it in GitHub Desktop.
Save obbaeiei/99e34ca82682fd49bfd0db097559355e to your computer and use it in GitHub Desktop.
Async/Await example
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