Open History to see the last commit
1const data = []
2β
3function shouldFail() {
4 return Math.random() > 0.7
5}
6β
7export default (req, res) => {
8 if (req.method === 'POST') {
9 const body = JSON.parse(req.body)
10β
11 // sometimes it will fail, this will cause a regression on the UI
12β
13 if (shouldFail()) {
14 throw new Error('Could not add item!')
15 }
16β
17 data.push(body.text.toUpperCase())
18 res.json(data)
19 return
20 }
21β
22 setTimeout(() => {
23 res.json(data)
24 }, 300)
25}