A
A
Alexey Yakovlev2020-11-06 19:09:58
MongoDB
Alexey Yakovlev, 2020-11-06 19:09:58

Can't find the selected size?

pug:

each size in product.sizes
       input(style="width:1px; height:1px; position:absolute;" type="checkbox" name="size")
       label.product__block-size(for="size")= size


How do I process POST request (add to cart):
router.post('/add', auth, async(req, res) => {
    try {
        const product = await Product.findById(
            req.body.id, req.body.title, req.body.nowPrice, req.body.mainSize,
            req.body.article, req.body.sex, req.body.size
        );

        console.log(req.body.size);

        await req.user.addToCart(product);
        res.redirect('/cart');
    } catch (e) {
        console.log(e);
    }
})


console.log returns undefined. What's wrong?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question