Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

api.ts

9 lines293 Bytes

1import type { Post } from './types'
2​
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()
8 },
9}