Skip to content

Commit

Permalink
display a specific meetup with a given id
Browse files Browse the repository at this point in the history
  • Loading branch information
murediane committed Jan 11, 2019
1 parent d80a5ce commit 1ec94f8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/server/controllers/meetups.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,10 @@ const createMeetups = (req, res) => {
meetups.push(meetup);
return res.send(meetup);
};
export { createMeetups };
const getMeetup = (req, res) => {
const { id } = req.params;
const meetup = meetups.find(m => m.id === parseInt(id));
if (!meetup) res.status(404).send('the meetup with a given id doesnot exist');
res.send(meetup);
};
export { createMeetups, getMeetup };
4 changes: 3 additions & 1 deletion src/server/routes/meetup.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import Router from 'express';
import { createMeetups } from '../controllers/meetups';
import { createMeetups, getMeetup } from '../controllers/meetups';
const router = Router();
const entry = '/meetups';
// create Meetups route

router.post(`${entry}`, createMeetups);
//get ameetup with aspecific Id
router.get(`${entry}/:id`, getMeetup);
export default router;

0 comments on commit 1ec94f8

Please sign in to comment.