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 const { add, clear } = req.query
11β
12 if (typeof add === 'string' && add) {
13 if (!list.includes(add)) {
14 list.push(add)
15 }
16 } else if (clear) {
17 list = []
18 }
19β
20 await new Promise((r) => setTimeout(r, 100))
21β
22 res.json(list)
23}