Promise not triggering .then() after fetch Express API/Mongoose call

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(, {$inc: {[conditionToUpdate]: amtToUpdate}}, (err, result) => {

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top