fix getHomeTerms api infinite call

This commit is contained in:
hyunwoo93.cha
2024-07-17 13:08:45 +09:00
parent 63be684d07
commit bd2ef87eb8
2 changed files with 17 additions and 9 deletions

View File

@@ -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());
});