Remove async/await

This commit is contained in:
Bubka
2020-01-19 22:29:36 +01:00
parent 3e1007b8fb
commit 8e4f8c4f8a
7 changed files with 115 additions and 111 deletions

View File

@ -60,23 +60,22 @@
},
methods : {
async handleSubmit(e) {
handleSubmit(e) {
e.preventDefault()
try {
const { data } = await axios.post('api/login', {
email: this.email,
password: this.password
})
localStorage.setItem('user',data.message.name)
localStorage.setItem('jwt',data.message.token)
axios.post('api/login', {
email: this.email,
password: this.password
})
.then(response => {
localStorage.setItem('user',response.data.message.name)
localStorage.setItem('jwt',response.data.message.token)
if (localStorage.getItem('jwt') != null){
this.$router.go('/');
}
}
catch (error) {
})
.catch(error => {
this.validationErrors = {}
this.errorMessage = ''
@ -90,7 +89,7 @@
else {
this.$router.push({ name: 'genericError', params: { err: error.response } });
}
}
});
}
},

View File

@ -82,25 +82,25 @@
},
methods : {
async handleSubmit(e) {
handleSubmit(e) {
e.preventDefault()
try {
const { data } = await axios.post('api/register', {
name: this.name,
email: this.email,
password: this.password,
password_confirmation : this.password_confirmation
})
axios.post('api/register', {
name: this.name,
email: this.email,
password: this.password,
password_confirmation : this.password_confirmation
})
.then(response => {
localStorage.setItem('user',data.message.name)
localStorage.setItem('jwt',data.message.token)
localStorage.setItem('user',response.data.message.name)
localStorage.setItem('jwt',response.data.message.token)
if (localStorage.getItem('jwt') != null){
this.$router.push({name: 'accounts'})
}
}
catch (error) {
})
.catch(error => {
this.validationErrors = {}
@ -110,7 +110,7 @@
else {
this.$router.push({ name: 'genericError', params: { err: error.response } });
}
}
});
}
},

View File

@ -46,19 +46,21 @@
}
},
methods : {
async handleSubmit(e){
handleSubmit(e){
e.preventDefault()
this.validationErrors = {}
try {
const { data } = await axios.post('/api/password/email', {
email: this.email
})
axios.post('/api/password/email', {
email: this.email
})
.then(response => {
this.response = response.data.status
})
.catch(error => {
this.response = data.status
}
catch (error) {
if( error.response.data.errors ) {
this.validationErrors = error.response.data.errors
}
@ -68,7 +70,9 @@
else {
this.$router.push({ name: 'genericError', params: { err: error.response } });
}
}
});
}
}
}

View File

@ -62,22 +62,24 @@
},
methods : {
async handleSubmit(e) {
handleSubmit(e) {
e.preventDefault()
this.validationErrors = {}
try {
const { data } = await axios.post('/api/password/reset', {
email: this.email,
password: this.password,
password_confirmation : this.password_confirmation,
token: this.token
})
axios.post('/api/password/reset', {
email: this.email,
password: this.password,
password_confirmation : this.password_confirmation,
token: this.token
})
.then(response => {
this.$router.go('/');
}
catch (error) {
})
.catch(error => {
if( error.response.data.errors ) {
this.validationErrors = error.response.data.errors
}
@ -87,7 +89,8 @@
else {
this.$router.push({ name: 'genericError', params: { err: error.response } });
}
}
});
}
},
}