import type { Post } from './types' export const postsAPI = { getPosts: async (): Promise> => { const response = await fetch('https://jsonplaceholder.typicode.com/posts') if (!response.ok) throw new Error('Failed to fetch posts') return await response.json() }, getPost: async (id: number): Promise => { const response = await fetch( `https://jsonplaceholder.typicode.com/posts/${id}`, ) if (!response.ok) throw new Error('Failed to fetch post') return await response.json() }, }