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

pokemon.ts

11 lines323 Bytes

1import { queryOptions } from '@tanstack/react-query'
2​
3export const pokemonOptions = queryOptions({
4 queryKey: ['pokemon'],
5 queryFn: async () => {
6 const response = await fetch('https://pokeapi.co/api/v2/pokemon/25')
7 if (!response.ok) throw new Error('Failed to fetch pokemon')
8​
9 return response.json()
10 },
11})