implements status code 404 in index

This commit is contained in:
Francesco Esposito 2019-02-22 10:09:38 +01:00
parent 31c147392b
commit 008b8f2360
1 changed files with 5 additions and 1 deletions

View File

@ -11,11 +11,15 @@ function index(req, res) {
return res.json(device);
});
} else {
Device.get((err, devices) => {
Device.find({}, (err, devices) => {
if (err) {
logger.logError(`index: ${err}`);
return res.status(500).send();
}
if (devices.length === 0) {
return res.status(404).send();
}
return res.json(devices);
});
}