added api route for retrieving single item

This commit is contained in:
notnull 2019-03-06 18:46:51 -05:00
parent e8af7ef7db
commit 5e6db1a67e

View File

@ -12,6 +12,15 @@ router.get('/', async (req, res, next) => {
}
})
router.get('/:id', async (req, res, next) => {
try {
const item = await Item.findById(req.params.id)
res.json(item)
} catch (err) {
next(err)
}
})
router.post('/', async (req, res, next) => {
try {
const item = await Item.create(req.body)