MSP-3105 fix eslint and add constants in styleConst
This commit is contained in:
1 parent
67691c58f2
commit
a380067908
5 files changed
+39
-30
No files matched your search
+22
-21
@@ -1,18 +1,19 @@
|
||||
import { BaseQueryFn, retry } from '@reduxjs/toolkit/query/react';
|
||||
import { BaseQueryFn, retry } from '@reduxjs/toolkit/query/react'
|
||||
import { AxiosError, AxiosRequestConfig } from 'axios'
|
||||
|
||||
import { AxiosError, AxiosRequestConfig } from 'axios';
|
||||
import { apiService } from '@services/apiService.ts'
|
||||
|
||||
import { MSPError } from '@type/index.ts'
|
||||
|
||||
export const axiosBaseQuery =
|
||||
(
|
||||
{ baseUrl }: { baseUrl: string } = { baseUrl: '' },
|
||||
{ baseUrl }: { baseUrl: string } = { baseUrl: '' }
|
||||
): BaseQueryFn<
|
||||
{
|
||||
url: string;
|
||||
method?: AxiosRequestConfig['method'];
|
||||
data?: AxiosRequestConfig['data'];
|
||||
params?: AxiosRequestConfig['params'];
|
||||
url: string
|
||||
method?: AxiosRequestConfig['method']
|
||||
data?: AxiosRequestConfig['data']
|
||||
params?: AxiosRequestConfig['params']
|
||||
},
|
||||
unknown,
|
||||
unknown
|
||||
@@ -23,29 +24,29 @@ export const axiosBaseQuery =
|
||||
url: baseUrl + url,
|
||||
method,
|
||||
data,
|
||||
params,
|
||||
});
|
||||
return { data: result.data };
|
||||
params
|
||||
})
|
||||
return { data: result.data }
|
||||
} catch (axiosError) {
|
||||
const err = axiosError as AxiosError<MSPError>;
|
||||
const err = axiosError as AxiosError<MSPError>
|
||||
return {
|
||||
error: { ...err.response },
|
||||
};
|
||||
error: { ...err.response }
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export const staggeredBaseQueryWithBailOut = (baseUrl: string) =>
|
||||
retry(
|
||||
async (args: string | AxiosRequestConfig['data'], api, extraOptions) => {
|
||||
const result = await axiosBaseQuery({ baseUrl })(args, api, extraOptions);
|
||||
const error = result.error as AxiosError<MSPError>;
|
||||
const result = await axiosBaseQuery({ baseUrl })(args, api, extraOptions)
|
||||
const error = result.error as AxiosError<MSPError>
|
||||
if (error && error?.status === 400) {
|
||||
retry.fail(result.error);
|
||||
retry.fail(result.error)
|
||||
}
|
||||
|
||||
return result;
|
||||
return result
|
||||
},
|
||||
{
|
||||
maxRetries: 5,
|
||||
},
|
||||
);
|
||||
maxRetries: 5
|
||||
}
|
||||
)
|
||||
Reference in new issue
Block a user