Skip to content

Instantly share code, notes, and snippets.

@Fl0pZz

Fl0pZz/.js Secret

Created January 24, 2017 10:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fl0pZz/001180ee41a73de33102388f73eef2a1 to your computer and use it in GitHub Desktop.
Save Fl0pZz/001180ee41a73de33102388f73eef2a1 to your computer and use it in GitHub Desktop.
authorize () {
let obj = this
this.$validator.validateAll('auth')
.then(success => {
if (success) {
console.log(obj)
// obj.login({
// email: obj.email,
// password: obj.password
// })
obj.login({ email, password } = obj)
.catch(error => {
obj.push({
type: nTypes.ERROR,
messages: Object.keys(error.response.data)
.map(key => {
return {
header: `${key.charAt(0).toUpperCase() + key.slice(1)}`,
message: error.response.data[key].join(' ')
}
}),
action: nActionTypes.CLOSE
})
})
} else {
obj.push({
type: nTypes.ERROR,
messages: [{ message: obj.errors.all().join('<br>') }],
action: nActionTypes.CLOSE
})
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment