User profile request caching

This commit is contained in:
2025-10-15 11:13:58 +02:00
parent f5aca7434f
commit a183974d20
6 changed files with 91 additions and 20 deletions
+2 -4
View File
@@ -1,10 +1,10 @@
"use client";
import { ProfileSettings } from "@/types/settings";
import axios from "axios";
import Cookies from "js-cookie";
import { useRouter } from "next/navigation";
import { useEffect, useState } from "react";
import { get } from "@/lib/request";
export interface UserProfile extends ProfileSettings {
id: string;
@@ -23,9 +23,7 @@ export default function useUser() {
}
try {
const res = (await axios.get("/api/profile")).data as UserProfile;
setUser(res);
setUser((await get("/api/profile")).data);
} catch {
router.push("/login");
}