Ad

Receiving Json With List Using Nodejs E Express

- 1 answer

I'm trying to receive a json with list of items in a nodejs code, but it doesn't works.

router.post('/', (req, res) => {
    models.sequelize.transaction().then(transation => {
        let entity = req.body;

If req.body it's just an element, works perfectly well.

Ad

Answer

Add app.use(bodyParser.json()); to your code, make sure the JSON could be parsed correctly.

Ad
source: stackoverflow.com
Ad