Last active
January 30, 2020 15:57
-
-
Save flexbox/e326bb24da5874f127789a86b6d3fc6a to your computer and use it in GitHub Desktop.
Async / await cheatsheet
This file contains 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 customerUpdate(fields) { | |
try { | |
const { status, data } = await this.$axios… | |
return { status, data } | |
} catch (e) { | |
throw new Error(e) | |
} | |
} |
This file contains 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 updateUserFields({ commit }, fields) { | |
commit('SET_LOADING', true) | |
const { status, data } = await this.$userApi.customerUpdate(fields) | |
commit('SET_LOADING', false) | |
commit('SET_USER', status === 200 ? data : null) | |
return status === 200 | |
}, |
This file contains 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 save() { | |
const birthday = … | |
const res = await this.updateUserFields({ birthday }) | |
if (res) { | |
this.$emit('success') | |
this.close() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment