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); return res.json(device);
}); });
} else { } else {
Device.get((err, devices) => { Device.find({}, (err, devices) => {
if (err) { if (err) {
logger.logError(`index: ${err}`); logger.logError(`index: ${err}`);
return res.status(500).send(); return res.status(500).send();
} }
if (devices.length === 0) {
return res.status(404).send();
}
return res.json(devices); return res.json(devices);
}); });
} }