Created
November 28, 2018 08:09
-
-
Save olehcambel/3bce7ae01fdab9633c03a580e84c7c3d to your computer and use it in GitHub Desktop.
promise \ callback => 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
const fetch = () => { | |
return new Promise((resolve, reject) => { | |
this.validate('name') | |
.then(result => { | |
return resolve(result.id) | |
}) | |
.catch(reject) | |
}) | |
} | |
const fetch = async () => { | |
const result = await this.validate('name') | |
return result.id | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment