fix(login): fixed the interceptor to handle multiple failures (#8071)

* fix(login): fixed the interceptor to handle multiple failures

* fix(login): fixed the interceptor to handle multiple failures
This commit is contained in:
Vikrant Gupta 2025-05-27 21:17:33 +05:30 committed by GitHub
parent 0ec1be1ddf
commit ae7364f098
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4,7 +4,11 @@
import getLocalStorageApi from 'api/browser/localstorage/get';
import loginApi from 'api/v1/login/login';
import afterLogin from 'AppRoutes/utils';
import axios, { AxiosResponse, InternalAxiosRequestConfig } from 'axios';
import axios, {
AxiosError,
AxiosResponse,
InternalAxiosRequestConfig,
} from 'axios';
import { ENVIRONMENT } from 'constants/env';
import { Events } from 'constants/events';
import { LOCALSTORAGE } from 'constants/localStorage';
@ -83,6 +87,7 @@ const interceptorRejected = async (
true,
);
try {
const reResponse = await axios(
`${value.config.baseURL}${value.config.url?.substring(1)}`,
{
@ -96,11 +101,13 @@ const interceptorRejected = async (
},
},
);
if (reResponse.status === 200) {
return await Promise.resolve(reResponse);
}
} catch (error) {
if ((error as AxiosError)?.response?.status === 401) {
Logout();
return await Promise.reject(reResponse);
}
}
} catch (error) {
Logout();
}