aboutsummaryrefslogtreecommitdiffstats
path: root/routes/api/members.js
diff options
context:
space:
mode:
Diffstat (limited to 'routes/api/members.js')
-rw-r--r--routes/api/members.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/routes/api/members.js b/routes/api/members.js
index 471cc14..f1498ae 100644
--- a/routes/api/members.js
+++ b/routes/api/members.js
@@ -56,4 +56,20 @@ router.put('/:id', (req, res) => {
}
});
+// Delete member
+router.delete('/:id', (req, res) => {
+ const found = members.some(member => member.id === parseInt(req.params.id));
+
+ if(found) {
+ res.json({ msg: 'Member deleted',
+ members: members.filter(member =>
+ member.id !== parseInt(req.params.id))});
+ res.json(members.filter(member =>
+ member.id !== parseInt(req.params.id)));
+ } else {
+ res.status(400).json({ msg: `No member with the id of ${req.params.id}`
+ });
+ }
+});
+
module.exports = router;