async function login(){
const id = document.getElementById('id').value;
const password = document.getElementById('password').value;
const data = {id, password};
const res = await fetch('/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data),
});
const result = await res.json();
if(result.success){
localStorage.setItem('token', result.token);
location.href = '/';
}else{
alert(result.msg);
}
}