@acrool/react-fetcher 0.0.10 → 0.0.11-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -12,5 +12,5 @@ export interface IFormatResponseErrorReturn {
|
|
|
12
12
|
export type TGetResponseFormatError = (axiosError?: AxiosError) => IFormatResponseErrorReturn;
|
|
13
13
|
export type TCheckIsRefreshTokenRequest = (config: IInternalRequestConfig) => boolean;
|
|
14
14
|
export type TCheckIsErrorResponse = (response: AxiosResponse) => boolean;
|
|
15
|
-
export type TCheckErrorIs401 = (error: IFormatResponseErrorReturn) => boolean;
|
|
16
|
-
export type TOnResponseError = (error: IFormatResponseErrorReturn) => void;
|
|
15
|
+
export type TCheckErrorIs401 = (error: IFormatResponseErrorReturn, httpStatus: string) => boolean;
|
|
16
|
+
export type TOnResponseError = (error: IFormatResponseErrorReturn, httpStatus: string) => void;
|
|
@@ -3182,9 +3182,9 @@ const FetcherProvider = ({
|
|
|
3182
3182
|
}
|
|
3183
3183
|
return response;
|
|
3184
3184
|
};
|
|
3185
|
-
const handleOnResponseError = (responseFirstError) => {
|
|
3185
|
+
const handleOnResponseError = (responseFirstError, httpStatus) => {
|
|
3186
3186
|
if (onResponseError) {
|
|
3187
|
-
onResponseError(responseFirstError);
|
|
3187
|
+
onResponseError(responseFirstError, httpStatus);
|
|
3188
3188
|
}
|
|
3189
3189
|
};
|
|
3190
3190
|
const interceptorsResponseError = (axiosError) => {
|
|
@@ -3196,14 +3196,14 @@ const FetcherProvider = ({
|
|
|
3196
3196
|
if (isDebug) u.warning("[FetcherProvider] interceptorsResponseError(2)", { status, responseFirstError });
|
|
3197
3197
|
const isRefresh = originalConfig && checkIsRefreshTokenRequest ? checkIsRefreshTokenRequest(originalConfig) : false;
|
|
3198
3198
|
if (response && originalConfig) {
|
|
3199
|
-
if (status === 401 || checkErrorIs401 && checkErrorIs401(responseFirstError)) {
|
|
3199
|
+
if (status === 401 || checkErrorIs401 && checkErrorIs401(responseFirstError, String(status))) {
|
|
3200
3200
|
const tokens = getTokens();
|
|
3201
3201
|
if (isDebug) u.warning("[FetcherProvider] enter refresh token flow", { refreshToken: tokens == null ? void 0 : tokens.refreshToken });
|
|
3202
3202
|
if (w(tokens == null ? void 0 : tokens.refreshToken) || isRefresh || originalConfig.pendingRequest) {
|
|
3203
3203
|
isTokenRefreshing = false;
|
|
3204
3204
|
if (isDebug) u.warning("[FetcherProvider] no refreshToken/refreshAPI|pendingRequest fail, force logout");
|
|
3205
3205
|
forceLogout();
|
|
3206
|
-
if (originalConfig.ignoreGlobalError !== true) handleOnResponseError(responseFirstError);
|
|
3206
|
+
if (originalConfig.ignoreGlobalError !== true) handleOnResponseError(responseFirstError, String(status));
|
|
3207
3207
|
return Promise.reject(new FetcherException(responseFirstError));
|
|
3208
3208
|
}
|
|
3209
3209
|
if (!isTokenRefreshing) {
|
|
@@ -3222,7 +3222,7 @@ const FetcherProvider = ({
|
|
|
3222
3222
|
});
|
|
3223
3223
|
}
|
|
3224
3224
|
}
|
|
3225
|
-
if (originalConfig.ignoreGlobalError !== true) handleOnResponseError(responseFirstError);
|
|
3225
|
+
if (originalConfig.ignoreGlobalError !== true) handleOnResponseError(responseFirstError, String(status));
|
|
3226
3226
|
return Promise.reject(new FetcherException(responseFirstError));
|
|
3227
3227
|
};
|
|
3228
3228
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|