2021-09-14 11:10:25 -05:00

15 lines
415 B
JavaScript

async function logout() {
const response = await fetch(`api/users/logout`, {
method: 'post',
headers: { 'Content-Type': 'application/json' }
});
if (response.ok) {
document.location.replace(`/`);
} else {
alert(response.statusText);
}
}
// Double check that #logout is actually the right name
document.querySelector(`#logout`).addEventListener(`click`, logout);