Skip to contentOpen History to see the last commit
api.ts
9 lines293 Bytes
1import type { Post } from './types' 3export const postsAPI = { 4 getPosts: async (): Promise<Array<Post>> => { 5 const response = await fetch('https://jsonplaceholder.typicode.com/posts') 6 if (!response.ok) throw new Error('Failed to fetch posts') 7 return await response.json()