Skip to content

Instantly share code, notes, and snippets.

@MkDierz
Created September 17, 2021 02:15
Show Gist options
  • Save MkDierz/3d501b85a904cfc2db3034a92c71c8ae to your computer and use it in GitHub Desktop.
Save MkDierz/3d501b85a904cfc2db3034a92c71c8ae to your computer and use it in GitHub Desktop.
function login() {
if (checker()) {
axios
.post('/api/login', {
username: username.value,
password: password.value
})
.catch(function (error) {
console.log(error);
alert(error)
})
.then(function (response) {
if (response.data.token) {
alert('token:'+response.data.token+'\nid:'+ response.data.user_id)
window.location.href = '/';
} else {
alert(response.data)
}
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment