Compare commits

..

No commits in common. "b6f335bc09edb0a665537fd605f594f365c2950f" and "c1b55c5d98b5e0b22b1416018db828ba59166522" have entirely different histories.

3 changed files with 35 additions and 48 deletions

View File

@ -9,7 +9,7 @@ export const customInstance = <T>(
config: AxiosRequestConfig,
options?: AxiosRequestConfig,
): CancelablePromise<T> => {
const abort = new AbortController();
const source = Axios.CancelToken.source();
/*
Hack to ensure that the data is passed to the request as an option.
@ -22,24 +22,19 @@ export const customInstance = <T>(
const instance = Axios.create({baseURL: options?.baseURL});
const promise = instance({
signal: abort.signal,
...config,
...options,
})
.then(({ data }) => data)
.catch((error) => {
cancelToken: source.token,
}).then(({data}) => data).catch((error) => {
if (Axios.isCancel(error)) {
return;
}
throw new S5Error(
(error as AxiosError).message,
(error as AxiosError).response?.status as number,
);
});
throw new S5Error((error as AxiosError).message, (error as AxiosError).response?.status as number);
})
// @ts-ignore
promise.cancel = () => {
abort.abort("Query was cancelled");
source.cancel("Query was cancelled");
};
return promise as CancelablePromise<T>;

View File

@ -18,7 +18,6 @@ export type CustomClientOptions = {
customCookie?: string;
onDownloadProgress?: (progressEvent: AxiosProgressEvent) => void;
onUploadProgress?: (progressEvent: AxiosProgressEvent) => void;
httpConfig?: AxiosRequestConfig;
};
export function optionsToConfig(
@ -30,7 +29,7 @@ export function optionsToConfig(
| CustomRegistryOptions
)[]
): AxiosRequestConfig {
let config: AxiosRequestConfig = {};
const config: AxiosRequestConfig = {};
config.baseURL = client.portalUrl;
@ -76,12 +75,5 @@ export function optionsToConfig(
config.headers = headers;
if (finalOptions?.httpConfig) {
config = {
...config,
...finalOptions.httpConfig,
};
}
return config;
}