2024-03-04 16:42:14 +03:00

25 lines
754 B
TypeScript

import getUrls from '@/config/urls';
import { withHandleError } from '@/utils/axios';
import type { QueryFunctionContext } from '@tanstack/react-query';
import axios from 'axios';
const { URL_CACHE_GET_QUERIES, URL_CACHE_DELETE_QUERY, URL_CACHE_FLUSH_ALL } = getUrls();
export function getQueries({ signal }: QueryFunctionContext) {
return withHandleError(axios.get(URL_CACHE_GET_QUERIES, { signal })).then(({ data }) => data);
}
export function deleteQuery(queryName: string) {
return withHandleError(
axios.delete(URL_CACHE_DELETE_QUERY, {
params: {
queryName,
},
})
).then(({ data }) => data);
}
export function flushAll() {
return withHandleError(axios.delete(URL_CACHE_FLUSH_ALL)).then(({ data }) => data);
}