Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use body-parser for post-resources #10

Open
bergjos opened this issue May 30, 2020 · 2 comments
Open

How to use body-parser for post-resources #10

bergjos opened this issue May 30, 2020 · 2 comments

Comments

@bergjos
Copy link

bergjos commented May 30, 2020

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.

@uptownhr
Copy link
Owner

uptownhr commented Jun 3, 2020

thanks for creating an issue. I need to double-check but this module may not be needed anymore. I believe nuxt today may have this baked in.

@uptownhr
Copy link
Owner

uptownhr commented Jun 3, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants