add view single device routes/controller
This commit is contained in:
parent
f3842099e1
commit
673857ee52
|
@ -7,4 +7,8 @@ router
|
|||
.route('/devices')
|
||||
.get(deviceController.index);
|
||||
|
||||
router
|
||||
.route('/devices/:deviceId')
|
||||
.get(deviceController.view);
|
||||
|
||||
module.exports = router;
|
||||
|
|
|
@ -10,4 +10,15 @@ function index(req, res) {
|
|||
});
|
||||
}
|
||||
|
||||
function view(req, res) {
|
||||
Device.findById(req.params.deviceId)
|
||||
.then((device) => {
|
||||
res.json(device);
|
||||
})
|
||||
.catch((err) => {
|
||||
res.send(err);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports.index = index;
|
||||
module.exports.view = view;
|
||||
|
|
Loading…
Reference in New Issue