diff options
| author | Pitu <[email protected]> | 2019-03-29 00:35:58 +0900 |
|---|---|---|
| committer | Pitu <[email protected]> | 2019-03-29 00:35:58 +0900 |
| commit | ea3e503d13b7be477c064b02b9b2e5a9ef06c9a9 (patch) | |
| tree | 8ffd0bef5e2e210ca28478d18c3876b73cc79784 /src/site/pages/register.vue | |
| parent | Added axios package (diff) | |
| download | host.fuwn.me-ea3e503d13b7be477c064b02b9b2e5a9ef06c9a9.tar.xz host.fuwn.me-ea3e503d13b7be477c064b02b9b2e5a9ef06c9a9.zip | |
Added middleware for pages and switched to $axios
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); - }); + } } } }; |