diff options
author | dartcafe <github@dartcafe.de> | 2021-02-27 13:10:48 +0300 |
---|---|---|
committer | dartcafe <github@dartcafe.de> | 2021-02-27 13:10:48 +0300 |
commit | 985fa6e5ebc878b00c64cd371079e45a491d2b58 (patch) | |
tree | a9a56b8afb4c56e316fddea30073f7e0ed280c7a /src/js/components/Create | |
parent | 7a05a361da2b5e0879e9e83dcb2f6d9fa3009671 (diff) |
use async/await
Signed-off-by: dartcafe <github@dartcafe.de>
Diffstat (limited to 'src/js/components/Create')
-rw-r--r-- | src/js/components/Create/CreateDlg.vue | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/js/components/Create/CreateDlg.vue b/src/js/components/Create/CreateDlg.vue index 17b8f9e8..e319354d 100644 --- a/src/js/components/Create/CreateDlg.vue +++ b/src/js/components/Create/CreateDlg.vue @@ -90,17 +90,16 @@ export default { this.$emit('close-create') }, - confirm() { - this.$store.dispatch('poll/add', { title: this.title, type: this.pollType }) - .then((response) => { - emit('update-polls') - this.cancel() - showSuccess(t('polls', 'Poll "{pollTitle}" added', { pollTitle: response.data.title })) - this.$router.push({ name: 'vote', params: { id: response.data.id } }) - }) - .catch(() => { - showError(t('polls', 'Error while creating Poll "{pollTitle}"', { pollTitle: this.title })) - }) + async confirm() { + try { + const response = await this.$store.dispatch('poll/add', { title: this.title, type: this.pollType }) + emit('update-polls') + this.cancel() + showSuccess(t('polls', 'Poll "{pollTitle}" added', { pollTitle: response.data.title })) + this.$router.push({ name: 'vote', params: { id: response.data.id } }) + } catch (e) { + showError(t('polls', 'Error while creating Poll "{pollTitle}"', { pollTitle: this.title })) + } }, setFocus() { |