score:1

Accepted answer

you are destructing a query which are added after a ? in a request. ie .com?cardid=777&value=10000

however in your original code you send it via the post body. change req.query to req.body to achieve the intended result.

router.post('/list/:id', tokencontroller.isavalidtoken, async (req, res) => {
    const { cardid, value } = req.body;
    console.log(value, cardid); // <- this prints 'undefined'

    try {
        const orderitem = await orderitemcontroller.createorderitem(value, req.params.id, cardid);
        res.json(orderitem);
    } catch (error) {
        errorcontroller.errorcallback(error, res);
    }
});

Related Query

More Query from same tag