Skip to content

Commit

Permalink
feat: accessToken가 만료되었을 경우 대응
Browse files Browse the repository at this point in the history
  • Loading branch information
eunbae0 committed Jan 31, 2024
1 parent b903a5f commit 3d5ea16
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
9 changes: 8 additions & 1 deletion src/api/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
type ErrorResponseType = {
code: string;
message: string;
status: number;
};

export type UserStyleType = 'MORNING' | 'DAY' | 'NIGHT';
export type UsageRankingLevel = 0 | 1 | 2 | 3;

Expand All @@ -21,4 +27,5 @@ export type RecapInfoType = {
usageRanking: Array<UsageRankingType>;
};

export type GetLibraryHistoriesResponse = RecapInfoType;
export type GetLibraryHistoriesResponse = RecapInfoType &
Partial<ErrorResponseType>;
12 changes: 7 additions & 5 deletions src/hooks/useInitApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ const useInitApp = () => {
}
};
const handleRecapInfo = async () => {
try {
const recapInfo = await APIService.getLibraryHistories();
setRecapInfo(recapInfo);
} catch (e) {
console.error(e);
const recapInfo = await APIService.getLibraryHistories();
if (recapInfo.status === 401) {
alert('서비스를 이용하기 위해 앱 재접속이 필요합니다.');
await uoslifeBridge.goBack();
return;
}
setRecapInfo(recapInfo);
console.log(recapInfo);
};

useEffect(() => {
Expand Down

0 comments on commit 3d5ea16

Please sign in to comment.