Skip to content

Instantly share code, notes, and snippets.

@neonerd
Created March 24, 2017 17:29
Show Gist options
  • Save neonerd/92da153fdc4bfbc814872c0a82e48ce3 to your computer and use it in GitHub Desktop.
Save neonerd/92da153fdc4bfbc814872c0a82e48ce3 to your computer and use it in GitHub Desktop.
Async / await wait
function wait (s) {
return new Promise((resolve, reject) => {
setTimeout(() => resolve(true), s)
})
}
async function main () {
console.log('start now')
await wait(2000)
console.log('end after 2 seconds')
}
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment