You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I created a post-resource trying to accept some data via the post-body:
router.post('/api/testPost', (req, res) => { console.log(req.params); //It works! console.log(req.query); //It works! console.log(req.body); // Doesn't work due to missing body-parsing });
After a quick research, I realized, that there isn't any body-parsing in the nuxt-express-module. If you create a express-server without nuxt, you would use something like that: const bodyParser = require('body-parser') // parse application/x-www-form-urlencoded app.use(bodyParser.urlencoded({ extended: false })) // parse application/json app.use(bodyParser.json())
In my opinion it would be nice, to create a possibillity via the options, to use a body-parser.
The text was updated successfully, but these errors were encountered:
I created a post-resource trying to accept some data via the post-body:
router.post('/api/testPost', (req, res) => {
console.log(req.params); //It works!
console.log(req.query); //It works!
console.log(req.body); // Doesn't work due to missing body-parsing
});
After a quick research, I realized, that there isn't any body-parsing in the nuxt-express-module. If you create a express-server without nuxt, you would use something like that:
const bodyParser = require('body-parser')
// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: false }))
// parse application/json
app.use(bodyParser.json())
In my opinion it would be nice, to create a possibillity via the options, to use a body-parser.
The text was updated successfully, but these errors were encountered: