Skip to content

Instantly share code, notes, and snippets.

@olehcambel
Created November 28, 2018 08:09
Show Gist options
  • Save olehcambel/3bce7ae01fdab9633c03a580e84c7c3d to your computer and use it in GitHub Desktop.
Save olehcambel/3bce7ae01fdab9633c03a580e84c7c3d to your computer and use it in GitHub Desktop.
promise \ callback => async \ await
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