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

api.ts

8 lines243 Bytes

1export const pokemonsAPI = {
2 getPokemon: async (id: number) => {
3 const response = await fetch(`https://pokeapi.co/api/v2/pokemon/${id}`)
4 if (!response.ok) throw new Error('Failed to fetch pokemon')
5​
6 return response.json()
7 },
8}