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

api.ts

23 lines482 Bytes

1import type { ProjectsPage } from './types'
2​
3export const projectsAPI = {
4 getProjects: async (page = 0): Promise<ProjectsPage> => {
5 'use server'
6​
7 const pageSize = 10
8​
9 const projects = Array(pageSize)
10 .fill(0)
11 .map((_, i) => {
12 const id = page * pageSize + (i + 1)
13 return {
14 name: 'Project ' + id,
15 id,
16 }
17 })
18​
19 await new Promise((r) => setTimeout(r, 1000))
20​
21 return { projects, hasMore: page < 9 }
22 },