#21 Made logout page

This commit is contained in:
2023-03-19 15:10:10 -04:00
parent 8b9bc96b93
commit 8600826afa
2 changed files with 26 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
import { useContext, useEffect } from "react";
import UserContext from "../contexts/UserContext";
import { makeRequest } from "../utils.ts";
const LogoutPage = () => {
const { setCurrentUser } = useContext(UserContext);
useEffect(() => {
const cleanup = async () => {
await makeRequest({
url: "http://localhost:5000/logout",
method: "POST",
});
await setCurrentUser({});
localStorage.removeItem("currentUser");
window.location.href = "/login";
};
cleanup();
}, []);
return <div></div>;
};
export default LogoutPage;