diff --git a/src/axios.ts b/src/axios.ts index da357ea..1b41741 100644 --- a/src/axios.ts +++ b/src/axios.ts @@ -9,7 +9,7 @@ export const customInstance = ( config: AxiosRequestConfig, options?: AxiosRequestConfig, ): CancelablePromise => { - const source = Axios.CancelToken.source(); + const abort = new AbortController(); /* Hack to ensure that the data is passed to the request as an option. @@ -22,9 +22,9 @@ export const customInstance = ( const instance = Axios.create({ baseURL: options?.baseURL }); const promise = instance({ + signal: abort.signal, ...config, ...options, - cancelToken: source.token, }) .then(({ data }) => data) .catch((error) => { @@ -39,7 +39,7 @@ export const customInstance = ( // @ts-ignore promise.cancel = () => { - source.cancel("Query was cancelled"); + abort.abort("Query was cancelled"); }; return promise as CancelablePromise;