2021-01-07 19:13:09 +01:00
|
|
|
import client from '@api/client'
|
|
|
|
import { AxiosError } from 'axios'
|
|
|
|
import { useQuery, UseQueryOptions } from 'react-query'
|
|
|
|
|
|
|
|
export type QueryKey = ['Lists']
|
|
|
|
|
|
|
|
const queryFunction = () => {
|
|
|
|
return client<Mastodon.List[]>({
|
|
|
|
method: 'get',
|
|
|
|
instance: 'local',
|
|
|
|
url: 'lists'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2021-01-11 21:36:57 +01:00
|
|
|
const useListsQuery = <TData = Mastodon.List[]>({
|
2021-01-07 19:13:09 +01:00
|
|
|
options
|
|
|
|
}: {
|
|
|
|
options?: UseQueryOptions<Mastodon.List[], AxiosError, TData>
|
|
|
|
}) => {
|
|
|
|
const queryKey: QueryKey = ['Lists']
|
|
|
|
return useQuery(queryKey, queryFunction, options)
|
|
|
|
}
|
|
|
|
|
2021-01-11 21:36:57 +01:00
|
|
|
export { useListsQuery }
|