Skip to content

Instantly share code, notes, and snippets.

/demo.js Secret

Created January 24, 2017 10:56
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 anonymous/5337347aae20ff6f1b8838481959b16f to your computer and use it in GitHub Desktop.
Save anonymous/5337347aae20ff6f1b8838481959b16f to your computer and use it in GitHub Desktop.
const demo = {
authorize() {
const pushError = (messages) => this.push({
type: nTypes.ERROR, messages, action: nActionTypes.CLOSE
});
this.$validator.validateAll('auth')
.then(success => {
if (!success) return pushError([{ message: obj.errors.all().join('<br>') }]);
const { email, password } = this;
this.login({ email, password }).catch(error => pushError(Object.keys(error.response.data).map(key => ({
header: `${key.charAt(0).toUpperCase() + key.slice(1)}`,
message: error.response.data[key].join(' ')
}))));
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment