tooot/src/utils/queryHooks/reports.ts

19 lines
550 B
TypeScript
Raw Normal View History

2022-12-22 01:21:51 +01:00
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
import apiInstance from '@utils/api/instance'
import { AxiosError } from 'axios'
2022-12-22 01:21:51 +01:00
export type QueryKeyRules = ['Rules']
const queryFunction = () =>
apiInstance<Mastodon.Rule[]>({
method: 'get',
url: 'instance/rules'
}).then(res => res.body)
const useRulesQuery = (params?: { options?: UseQueryOptions<Mastodon.Rule[], AxiosError> }) => {
const queryKey: QueryKeyRules = ['Rules']
return useQuery(queryKey, queryFunction, params?.options)
}
export { useRulesQuery }