mirror of https://github.com/tooot-app/app
24 lines
566 B
TypeScript
24 lines
566 B
TypeScript
import apiInstance from '@api/instance'
|
|
import { AxiosError } from 'axios'
|
|
import { useQuery, UseQueryOptions } from 'react-query'
|
|
|
|
type QueryKey = ['Emojis']
|
|
|
|
const queryFunction = () => {
|
|
return apiInstance<Mastodon.Emoji[]>({
|
|
method: 'get',
|
|
url: 'custom_emojis'
|
|
}).then(res => res.body)
|
|
}
|
|
|
|
const useEmojisQuery = <TData = Mastodon.Emoji[]>({
|
|
options
|
|
}: {
|
|
options?: UseQueryOptions<Mastodon.Emoji[], AxiosError, TData>
|
|
}) => {
|
|
const queryKey: QueryKey = ['Emojis']
|
|
return useQuery(queryKey, queryFunction, options)
|
|
}
|
|
|
|
export { useEmojisQuery }
|