Skip to content

Commit

Permalink
feat: 데이터 응답값 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
lgrin-byte committed Dec 27, 2024
1 parent 96768bf commit 88b977f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
14 changes: 10 additions & 4 deletions app/lib/reactQueryProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
setLoginInfo,
} from "@/utils/storageUtil";

// Axios 클라이언트 설정
export const apiClient = axios.create({
withCredentials: true,
});
Expand Down Expand Up @@ -77,11 +78,16 @@ apiClient.interceptors.response.use(
}
);

const newAccessToken = data.accessToken;
setLoginInfo({ ...loginInfo, accessToken: newAccessToken });
apiClient.defaults.headers.Authorization = `Bearer ${newAccessToken}`;
const { data: response } = data;

processQueue(null, newAccessToken);
setLoginInfo({
...loginInfo,
refreshToken: response.refreshToken,
accessToken: response.accessToken,
});
apiClient.defaults.headers.Authorization = `Bearer ${response.accessToken}`;

processQueue(null, response.accessToken);
return apiClient(originalRequest);
} catch (refreshError) {
processQueue(refreshError, null);
Expand Down
4 changes: 2 additions & 2 deletions app/utils/storageUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ export const setLoginInfo = (loginInfo: LoginInfo) => {
const sessionStorage = window.sessionStorage;
setStorage(sessionStorage, ACCESS_TOKEN, accessToken);
setStorage(sessionStorage, REFRESH_TOKEN, refreshToken);
setStorage(sessionStorage, SHOP_NAME, shopName);
setStorage(sessionStorage, ADMIN_CODE, adminCode);
setStorage(sessionStorage, SHOP_NAME, shopName?.replaceAll(`"`, ""));
setStorage(sessionStorage, ADMIN_CODE, adminCode?.replaceAll(`"`, ""));
setStorage(sessionStorage, ACCESS_TOKEN_EXPIRES_IN, accessTokenExpiresIn);
};

Expand Down

0 comments on commit 88b977f

Please sign in to comment.