Open History to see the last commit
1import { queryOptions } from '@tanstack/react-query'
2β
3type DogsResp = {
4 message: {
5 [dog: string]: Array<string>
6 }
7}
8β
9const getDogs = async (): Promise<DogsResp> => {
10 const res = await fetch('https://dog.ceo/api/breeds/list/all')
11 if (!res.ok) throw new Error('something went wrong')
12 return await res.json()
13}
14β
15export const dogsQueryOptions = queryOptions({
16 queryKey: ['dogs'],
17 queryFn: getDogs,
18})