User profile request caching
This commit is contained in:
@@ -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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user