Added logout function.

This commit is contained in:
Luna 2021-07-23 07:30:24 -07:00
parent 4d5d32a064
commit b735929a02

20
logout.js Normal file
View file

@ -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')
}