import client from '@api/client' import { AxiosError } from 'axios' import { useQuery, UseQueryOptions } from 'react-query' export type QueryKey = ['Account', { id: Mastodon.Account['id'] }] const queryFunction = ({ queryKey }: { queryKey: QueryKey }) => { const { id } = queryKey[1] return client({ method: 'get', instance: 'local', url: `accounts/${id}` }).then(res => res.body) } const useAccountQuery = ({ options, ...queryKeyParams }: QueryKey[1] & { options?: UseQueryOptions }) => { const queryKey: QueryKey = ['Account', { ...queryKeyParams }] return useQuery(queryKey, queryFunction, options) } export { useAccountQuery }