You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

42 lines
1022 B

if (localStorage.getItem("token")!==null) {
// redirect to dashboard
window.location.href = "/dashboard.html";
}
function register() {
let email = document.getElementById("registerEmail").value;
let name = document.getElementById("registerName").value;
let password = document.getElementById("registerPassword").value;
let data = {
email: email,
name: name,
password: password
};
axios.post(url + "/register", data)
.then(function (res) {
console.log(res.data);
})
.catch(function (error) {
console.log(error);
});
}
function login() {
let email = document.getElementById("loginEmail").value;
let password = document.getElementById("loginPassword").value;
let data = {
email: email,
password: password
};
axios.post(url + "/login", data)
.then(function (res) {
console.log(res.data);
localStorage.setItem("token", res.data.token);
window.location.href = "/dashboard.html";
})
.catch(function (error) {
console.log(error);
});
}