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-urlencodedapp.use(bodyParser.urlencoded({ extended: false }))// parse application/jsonapp.use(bodyParser.json())
In my opinion it would be nice, to create a possibillity via the options, to use a body-parser.
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.