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

api.ts

11 lines332 Bytes

1import type { Location } from './types'
2​
3export const locationsAPI = {
4 getLocation: async (locationId: string): Promise<Location> => {
5 const res = await fetch(
6 `https://rickandmortyapi.com/api/location/${locationId}`,
7 )
8 if (!res.ok) throw new Error('Failed to fetch location')
9 return await res.json()
10 },