From a057cad4c6910aed732d1f2806278b77f483b70a Mon Sep 17 00:00:00 2001 From: YoujungSon Date: Mon, 27 Mar 2023 17:29:50 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20get=EC=9A=94=EC=B2=AD=20=EC=BA=90?= =?UTF-8?q?=EC=8B=B1=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/assetInstance.ts | 1 - src/components/dashboard/AssetList.tsx | 10 +++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/apis/assetInstance.ts b/src/apis/assetInstance.ts index 31a76c5..f3eb178 100644 --- a/src/apis/assetInstance.ts +++ b/src/apis/assetInstance.ts @@ -45,7 +45,6 @@ AxiosInstance.interceptors.response.use( localStorage.clear(); window.location.href = '/'; } - return Promise.reject(error); }, ); diff --git a/src/components/dashboard/AssetList.tsx b/src/components/dashboard/AssetList.tsx index 0fb4caf..034f1a2 100644 --- a/src/components/dashboard/AssetList.tsx +++ b/src/components/dashboard/AssetList.tsx @@ -14,11 +14,19 @@ const AssetList = () => { const [assetList, setAssetList] = useState([]); const searchText = useRecoilValue(searchTextState); + useEffect(() => { + const token = window.localStorage.getItem('token'); + if (!token) { + alert('로그인이 필요한 페이지 입니다. 로그인해주세요.'); + localStorage.clear(); + window.location.href = '/'; + } + }, []); const { data, status } = useQuery({ queryKey: ['getAsset'], queryFn: async () => await getAsset(), retry: 0, // 실패시 재호출 몇번 할지 - keepPreviousData: true, + cacheTime: 10000, // 10초 동안 캐싱 onSuccess: (data) => { data.data.asset === 'does not exist asset'; const list = data?.data?.asset?.Assets;