Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

api.ts

18 lines415 Bytes

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()
14​
15export const dogsQueryOptions = queryOptions({
16 queryKey: ['dogs'],
17 queryFn: getDogs,
18})