TP-32558 | Hide toast on failure | Himanshu Kansal

This commit is contained in:
Himanshu Kansal
2023-07-11 11:21:28 +05:30
parent 50cb51b5e4
commit af6641e2b6
2 changed files with 11 additions and 2 deletions

View File

@@ -80,6 +80,9 @@ export const syncCaseDetail =
const url = getApiUrl(ApiKeys.FEEDBACK);
axiosInstance
.post(url, payload, {
headers: {
donotHandleErrorOnStatusCode: [API_STATUS_CODE.UNPROCESSABLE_CONTENT].map(String),
},
params: {
forceSubmit: payload.forceSubmit,
apiVersion: SUBMIT_FEEDBACK_API_VERSION,

View File

@@ -214,8 +214,14 @@ axiosInstance.interceptors.response.use(
const end = Date.now();
const milliseconds = end - Number(start);
sendApiToClickstreamEvent(response, milliseconds, false);
if (config.headers.donotHandleError) {
console.log({ header: config.headers.donotHandleErrorOnStatusCode, error });
const donotHandleErrorOnStatusCode = (config.headers.donotHandleErrorOnStatusCode || []).map(
Number
);
if (
config.headers.donotHandleError ||
donotHandleErrorOnStatusCode.includes(error.response.status)
) {
return Promise.reject(error);
}
if (!config || config.retry <= 1 || !errorsToRetry.includes(error.response.status)) {