diff options
Diffstat (limited to 'src/site/pages/register.vue')
| -rw-r--r-- | src/site/pages/register.vue | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/site/pages/register.vue b/src/site/pages/register.vue index 9b882d6..bb17298 100644 --- a/src/site/pages/register.vue +++ b/src/site/pages/register.vue @@ -72,24 +72,26 @@ export default { return { title: 'Register' }; }, methods: { - register() { + async register() { if (this.isLoading) return; if (this.password !== this.rePassword) { this.$showToast('Passwords don\'t match', true); return; } this.isLoading = true; - this.axios.post(`${this.config.baseURL}/auth/register`, { - username: this.username, - password: this.password - }).then(response => { - this.$showToast(response.data.message); - this.isLoading = false; + + try { + const response = await this.$axios.$post(`auth/register`, { + username: this.username, + password: this.password + }); + this.$showToast(response.message); return this.$router.push('/login'); - }).catch(err => { + } catch (error) { + this.$onPromiseError(error); + } finally { this.isLoading = false; - this.$onPromiseError(err); - }); + } } } }; |