From bd2ef87eb8289212f22f087084317493169f006e Mon Sep 17 00:00:00 2001 From: "hyunwoo93.cha" Date: Wed, 17 Jul 2024 13:08:45 +0900 Subject: [PATCH] fix getHomeTerms api infinite call --- com.twin.app.shoptime/src/actions/homeActions.js | 16 +++++++++------- com.twin.app.shoptime/src/api/TAxios.js | 10 ++++++++-- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/com.twin.app.shoptime/src/actions/homeActions.js b/com.twin.app.shoptime/src/actions/homeActions.js index 8aeeb138..c3c64cd4 100644 --- a/com.twin.app.shoptime/src/actions/homeActions.js +++ b/com.twin.app.shoptime/src/actions/homeActions.js @@ -1,7 +1,10 @@ -import { URLS } from "../api/apiConfig"; -import { TAxios } from "../api/TAxios"; -import { types } from "./actionTypes"; -import { changeAppStatus, getTermsAgreeYn } from "./commonActions"; +import { URLS } from '../api/apiConfig'; +import { TAxios } from '../api/TAxios'; +import { types } from './actionTypes'; +import { + changeAppStatus, + getTermsAgreeYn, +} from './commonActions'; // 약관 정보 조회 IF-LGSP-005 export const getHomeTerms = (props) => (dispatch, getState) => { @@ -10,7 +13,7 @@ export const getHomeTerms = (props) => (dispatch, getState) => { const onSuccess = (response) => { console.log("getHomeTerms onSuccess ", response.data); - if(response.data.retCode === 0){ + if (response.data.retCode === 0) { dispatch({ type: types.GET_HOME_TERMS, payload: response.data, @@ -33,8 +36,7 @@ export const getHomeTerms = (props) => (dispatch, getState) => { { trmsTpCdList, mbrNo }, {}, onSuccess, - onFail, - true + onFail ); }; diff --git a/com.twin.app.shoptime/src/api/TAxios.js b/com.twin.app.shoptime/src/api/TAxios.js index e5fe8c5a..b5c82ff8 100644 --- a/com.twin.app.shoptime/src/api/TAxios.js +++ b/com.twin.app.shoptime/src/api/TAxios.js @@ -18,9 +18,9 @@ import { ACTIVE_POPUP } from "../utils/Config"; import * as HelperMethods from "../utils/helperMethods"; import { getUrl, URLS } from "./apiConfig"; -const retryCount = 0; -const MAX_COUNT = 10; +let retryCount = 0; let tokenRefreshing = false; + export const setTokenRefreshing = (value) => { console.log("TAxios setTokenRefreshing ", value); tokenRefreshing = value; @@ -42,10 +42,16 @@ export const TAxios = ( const accessToken = getState().localSettings.accessToken; if (noTokenRefresh || (!tokenRefreshing && accessToken)) { resolve(accessToken); + retryCount = 0; } else { if (!accessToken && !tokenRefreshing) { dispatch(getAuthenticationCode()); } + retryCount++; + if (retryCount > 5) { + return; + } + HelperMethods.wait(100).then(() => { resolve(checkAccessToken()); });