aboutsummaryrefslogtreecommitdiff
path: root/src/conf/mutator.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/conf/mutator.ts')
-rw-r--r--src/conf/mutator.ts29
1 files changed, 0 insertions, 29 deletions
diff --git a/src/conf/mutator.ts b/src/conf/mutator.ts
deleted file mode 100644
index 74f29e3..0000000
--- a/src/conf/mutator.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-import Axios, { AxiosError, AxiosRequestConfig } from "axios";
-
-export const AXIOS_PANTRY_INSTANCE = Axios.create({
- baseURL: process.env.REACT_APP_API_SERVER!,
-});
-
-export const useMutator = <T>(): ((
- config: AxiosRequestConfig
-) => Promise<T>) => {
- return (config: AxiosRequestConfig) => {
- const source = Axios.CancelToken.source();
- const promise = AXIOS_PANTRY_INSTANCE({
- ...config,
- cancelToken: source.token,
- }).then(({ data }) => data);
-
- // @ts-ignore
- promise.cancel = () => {
- source.cancel("Query was cancelled by React Query!");
- };
-
- return promise;
- };
-};
-
-export default useMutator;
-
-// In some case with react-query and swr you want to be able to override the return error type so you can also do it here like this
-export type ErrorType<Error> = AxiosError<Error>;