aboutsummaryrefslogtreecommitdiffstats
path: root/routes/api
diff options
context:
space:
mode:
Diffstat (limited to 'routes/api')
-rw-r--r--routes/api/members.js13
1 files changed, 12 insertions, 1 deletions
diff --git a/routes/api/members.js b/routes/api/members.js
index a7c71cd..c0186f6 100644
--- a/routes/api/members.js
+++ b/routes/api/members.js
@@ -1,4 +1,5 @@
const express = require('express');
+const uuid = require('uuid/v4');
const router = express.Router();
const members = require('../../Members');
@@ -21,8 +22,18 @@ router.get('/:id', (req, res) => {
// Create Member
router.post('/', (req, res) => {
const newMember = {
-
+ id: uuid(),
+ name: req.body.name,
+ email: req.body.email,
+ status: 'active'
}
+
+ if(!newMember.name || !newMember.email) {
+ return res.status(400).json({ msg: 'Please populate name and email' });
+ }
+
+ members.push(newMember);
+ res.json(members);
});
module.exports = router;