Created
September 5, 2018 08:44
-
-
Save oomusou/8a6a41e65fbfde5da1549c800b4987f5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
onSubmit() { | |
this.loading = true; | |
const body = () => ({ | |
username: this.username, | |
password: this.password, | |
}); | |
const processResponse = (response) => { | |
this.loading = false; | |
if (response.data.success) { | |
this.loggedUser = response.data.username; | |
} else { | |
this.error = 'Incorrect username/password'; | |
} | |
}; | |
const error = e => console.log(e); | |
axios | |
.post(`${API}/api/login`, body()) | |
.then(processResponse) | |
.catch(error); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment