fix react query bug
This commit is contained in:
parent
81eb55e2e0
commit
9b3c1fb49b
|
|
@ -50,9 +50,12 @@ function useAxios() {
|
||||||
return response;
|
return response;
|
||||||
},
|
},
|
||||||
function (error) {
|
function (error) {
|
||||||
console.log(error?.response);
|
// Reject errors with non-2xx status codes
|
||||||
|
const status = error?.response?.status;
|
||||||
|
if (status >= 400) {
|
||||||
|
return Promise.reject(error);
|
||||||
|
}
|
||||||
|
|
||||||
const status = error?.request?.status;
|
|
||||||
const errorMsg = error?.response?.data?.error;
|
const errorMsg = error?.response?.data?.error;
|
||||||
const errorField = error?.response?.data;
|
const errorField = error?.response?.data;
|
||||||
const method = error.config.method;
|
const method = error.config.method;
|
||||||
|
|
@ -65,8 +68,6 @@ function useAxios() {
|
||||||
? errorMsg
|
? errorMsg
|
||||||
: errorMsg?.[ErrorKey]?.[0] ??
|
: errorMsg?.[ErrorKey]?.[0] ??
|
||||||
t("validation.some_thing_went_wrong");
|
t("validation.some_thing_went_wrong");
|
||||||
console.log(isString);
|
|
||||||
|
|
||||||
toast.error(t(`${isString}`));
|
toast.error(t(`${isString}`));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -80,8 +81,11 @@ function useAxios() {
|
||||||
toast.error(errorMessage);
|
toast.error(errorMessage);
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
}
|
}
|
||||||
},
|
|
||||||
|
return Promise.reject(error); // Important to reject the promise
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
return build_Axios;
|
return build_Axios;
|
||||||
|
|
||||||
// return buildAxios.build();
|
// return buildAxios.build();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user