Skip to content

Instantly share code, notes, and snippets.

@dig1t
Last active December 30, 2023 04:44
Show Gist options
  • Save dig1t/56db72a3b1e6a674b43352160e731eb6 to your computer and use it in GitHub Desktop.
Save dig1t/56db72a3b1e6a674b43352160e731eb6 to your computer and use it in GitHub Desktop.
const yourAsyncFunction = async () => {
// do stuff
console.log('this will run first')
await new Promise((resolve, reject) => {
console.log('this will run second in 1000ms')
setTimeout(() => resolve(), 1000)
})
// do stuff after waiting for the timeout to resolve
console.log('this will run last')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment