diff options
author | William Harrington <kb0iic@berzerkula.org> | 2019-04-17 23:17:06 -0500 |
---|---|---|
committer | William Harrington <kb0iic@berzerkula.org> | 2019-04-17 23:17:06 -0500 |
commit | c23fe800aa5748398c6b49c25e73765e36dcb17c (patch) | |
tree | ca7f23f516f869ff6136365c17eb07cafbd97b4d /routes/api | |
parent | a4cdb24995e143ffeceb8d959b5670dbfa630c29 (diff) |
Add new member functionality
Diffstat (limited to 'routes/api')
-rw-r--r-- | routes/api/members.js | 13 |
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; |