aboutsummaryrefslogtreecommitdiffstats
path: root/routes/api/members.js
blob: d1c3bf956db601c7db10690e1128ea537b9e9edc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const express = require('express');
const router = express.Router();


// Gets all members
router.get('/api/members', (req, res) => res.json(members));

// Get single member
router.get('/api/members/:id', (req, res) => {
	const found = members.some(member => member.id === parseInt(req.params.id));

	if(found) {
		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}`
		});
	}
});