Open History to see the last commit
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)
21}