Skip to content

Instantly share code, notes, and snippets.

@oomusou
Created September 5, 2018 08:44
Show Gist options
  • Save oomusou/8a6a41e65fbfde5da1549c800b4987f5 to your computer and use it in GitHub Desktop.
Save oomusou/8a6a41e65fbfde5da1549c800b4987f5 to your computer and use it in GitHub Desktop.
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