Skip to content

Commit 42e30dc

Browse files
committed
POST /expense
1 parent 5ea2c14 commit 42e30dc

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

tripcost/server.js

+20-3
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,30 @@ app.get('/trips', (req, res) => {
4747
}
4848
res.status(200).json({ trips:items });
4949
});
50-
5150
});
5251

53-
app.post('/expense', (req, res) => { /* */ });
52+
app.post('/expense', (req, res) => {
5453

55-
app.get('/expenses', (req, res) => { /* */ });
54+
expenses.insertOne(
55+
56+
{ trip: req.body.trip,
57+
date: req.body.date,
58+
amount: req.body.amount,
59+
category: req.body.category,
60+
description: req.body.description
61+
},
62+
(err, result) => {
63+
if (err) {
64+
console.error(err);
65+
res.status(500).json({ err: err });
66+
return;
67+
}
68+
69+
res.status(200).json({ ok: true });
70+
});
71+
});
5672

73+
app.get('/expenses', (req, res) => { /* */ });
5774

5875
///////////////////////////////////
5976

0 commit comments

Comments
 (0)