Added logout function.
parent
4d5d32a064
commit
b735929a02
|
@ -0,0 +1,20 @@
|
|||
//VARIBLES
|
||||
|
||||
let username = localStorage.getItem('username');
|
||||
|
||||
//LOGOUT FETCH FUNCTION
|
||||
|
||||
async function logout() {
|
||||
let sendLogoutInfo = { "name": username }
|
||||
fetch('/api/logout/', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(sendRegisterInfo),
|
||||
});
|
||||
document.querySelector("#errormessage").innerHTML = 'Logged out.'
|
||||
localStorage.removeItem('username')
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue