Last active
June 15, 2017 23:18
-
-
Save RobsonX4/ae570779f4bcd8b860b7428ec1cf84ff to your computer and use it in GitHub Desktop.
nodejs: async await
This file contains hidden or 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 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