Formatting + Added Home Page
This commit is contained in:
@@ -16,4 +16,24 @@ document.addEventListener("DOMContentLoaded", async () => {
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
logoutButton.addEventListener("click", async (e) => {
|
||||
e.preventDefault();
|
||||
try {
|
||||
const logoutRes = await fetch('/logout', {
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
});
|
||||
|
||||
if (logoutRes.ok) {
|
||||
document.cookie = "authorization=; Max-Age=0; path=/;";
|
||||
window.location.href = "/login";
|
||||
} else {
|
||||
console.log("Failed to logout");
|
||||
}
|
||||
} catch (err) {
|
||||
console.log("Logout error:", err);
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user