Added logout function.

main
Luna 2021-07-23 07:30:24 -07:00
parent 4d5d32a064
commit b735929a02
1 changed files with 20 additions and 0 deletions

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