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

data.ts

21 lines460 Bytes

1import type { NextApiRequest, NextApiResponse } from 'next'
2​
3// an simple endpoint for getting current list
4let list = ['Item 1', 'Item 2', 'Item 3']
5​
6export default async (
7 req: NextApiRequest,
8 res: NextApiResponse<typeof list>,
9) => {
10 if (req.query.add) {
11 if (!list.includes(req.query.add)) {
12 list.push(req.query.add)
13 }
14 } else if (req.query.clear) {
15 list = []
16 }
17​
18 await new Promise((r) => setTimeout(r, 100))
19​
20 res.json(list)