Open History to see the last commit
1import type { Film, Paginated } from './types'
2β
3export const filmsAPI = {
4 getFilms: async (): Promise<Paginated<Film>> => {
5 const res = await fetch('https://swapi.dev/api/films/')
6 if (!res.ok) throw new Error('Failed to fetch films')
7 return await res.json()
8 },
9 getFilm: async (filmId: string): Promise<Film> => {
10 const res = await fetch(`https://swapi.dev/api/films/${filmId}/`)
11 if (!res.ok) throw new Error('Failed to fetch film')
12 return await res.json()
13 },
14}