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

api.ts

11 lines324 Bytes

1import type { Comment } from './types'
2​
3export const commentsAPI = {
4 getComments: async (): Promise<Array<Comment>> => {
5 const response = await fetch(
6 'https://jsonplaceholder.typicode.com/comments',
7 )
8 if (!response.ok) throw new Error('Failed to fetch comments')
9 return await response.json()
10 },