added api route for retrieving single item
This commit is contained in:
parent
e8af7ef7db
commit
5e6db1a67e
@ -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) => {
|
router.post('/', async (req, res, next) => {
|
||||||
try {
|
try {
|
||||||
const item = await Item.create(req.body)
|
const item = await Item.create(req.body)
|
||||||
|
Loading…
Reference in New Issue
Block a user