Skip to content

Instantly share code, notes, and snippets.

@RobsonX4
Last active June 15, 2017 23:18
Show Gist options
  • Select an option

  • Save RobsonX4/ae570779f4bcd8b860b7428ec1cf84ff to your computer and use it in GitHub Desktop.

Select an option

Save RobsonX4/ae570779f4bcd8b860b7428ec1cf84ff to your computer and use it in GitHub Desktop.
nodejs: async await
async function promise01() {
return new Promise((res, rej) => {
setTimeout(() => {
console.log('Promise 01')
res('Promise 01')
}, 2000)
})
}
async function promise02() {
return new Promise((res, rej) => {
console.log('Promise 02')
res('Promise 02')
})
}
async function testAsyn() {
console.log('START')
await promise01()
await promise02()
console.log('END')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment