Skip to contentOpen History to see the last commit
api.ts
11 lines313 Bytes
1import type { User } from './types' 3export const usersAPI = { 4 getUser: async (id: number): Promise<User> => { 5 const response = await fetch( 6 `https://jsonplaceholder.typicode.com/users/${id}`, 8 if (!response.ok) throw new Error('Failed to fetch user') 9 return await response.json()