Skip to contentOpen History to see the last commit
api.ts
9 lines295 Bytes
1import type { Planet } from './types' 3export const planetsAPI = { 4 getPlanet: async (planetId: string): Promise<Planet> => { 5 const res = await fetch(`https://swapi.dev/api/planets/${planetId}/`) 6 if (!res.ok) throw new Error('Failed to fetch planet') 7 return await res.json()