Skip to content

Commit

Permalink
Merge pull request #82 from nullchilly/hot-fix
Browse files Browse the repository at this point in the history
fix: fetch history
  • Loading branch information
nullchilly authored Dec 31, 2023
2 parents a4b7f05 + 49db2d8 commit 529a1ba
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/app/profile/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ const ProfilePage = () => {
const { name, accessToken } = useContext(UserContext);
const [gamesPlayed, setGamesPlayed] = useState([]);
useEffect(() => {
const savedToken = localStorage.getItem("accessToken");
async function fetchUserGame() {
const savedToken = localStorage.getItem("accessToken");
const response = await fetch(
`${process.env.NEXT_PUBLIC_BACKEND_URL}` + "/api/game/history",
{
Expand All @@ -242,7 +242,9 @@ const ProfilePage = () => {
setGamesPlayed(allGamesSlug);
}
}
fetchUserGame();
if (savedToken || accessToken){
fetchUserGame();
}
}, []);
return (
<div className="flex flex-col">
Expand Down

0 comments on commit 529a1ba

Please sign in to comment.