Throw an error when a prediction cannot be found
This commit is contained in:
parent
f23f580a25
commit
9b75741f22
@ -17,9 +17,10 @@ router.post('/prediction/new', (req, res, next) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
router.post('/prediction/compare', async (req, res, next) => {
|
router.post('/prediction/compare', async (req, res, next) => {
|
||||||
const valA = (await PredictionModel.findOne({ name: req.body.nameA })).value;
|
const valA = await PredictionModel.findOne({ name: req.body.nameA });
|
||||||
const valB = (await PredictionModel.findOne({ name: req.body.nameB })).value;
|
const valB = await PredictionModel.findOne({ name: req.body.nameB });
|
||||||
res.json(valB - valA);
|
if(!valA || !valB) next(new Error("invalid prediction name"));
|
||||||
|
res.json(valB.value - valA.value);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user