You’re returning the promise and resolving it, but you aren’t sending any response back to the client with the res
.
In the express code, you don’t need to have a promise, you can do this:
router.put('/:id', (req, res) => {
const conditionToUpdate = "q" + req.body.cond;
const amtToUpdate = req.body.op === 'incQuantity' ? 1 : -1;
Pokemon.findByIdAndUpdate(req.params.id, {$inc: {[conditionToUpdate]: amtToUpdate}}, (err, result) => {
res.json(result);
}));
});
CLICK HERE to find out more related problems solutions.