Skip to content

#415 Missing body for POST request in middleware #576

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

Merged
merged 17 commits into from
Jul 14, 2017

Conversation

JHotterbeekx
Copy link
Contributor

As described in issue 415, the body of post requests was no longer available in middlewares, since version 0.9.0.

The issue was caused by the removal of the 'body-parser' from the server/defaults.js. After re-adding this parser there, the body became available again in the middleware. I've also added an extra test, to verify that the post body is indeed available in the middleware, to prevent future changes to break this again,

serverReady(PORT, done)
})

it('Should have post body in middleware', (done) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: lowcase "s" in "should"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the line, and also updated the code to the new standards. Is it okay to get accepted now? I'd love to have this in the next release.

@JHotterbeekx
Copy link
Contributor Author

Any chance to accept this pull request so we can move on from version 0.8.23?

@typicode
Copy link
Owner

typicode commented Jul 12, 2017

Hi

Sorry for the delay, and thank you for the PR, AFAIR I think it was removed on purpose, because it was conflicting in some cases when the project was used as a module in another Express app (can't remember the issue).

If the idea is to make it available to middlewares loaded by the CLI, would it be possible to make it an option of jsonServer.defaults, like { bodyParser: true }, and enable it only in the CLI?

@JHotterbeekx
Copy link
Contributor Author

I've just updated the code that I think you meant for it to be, could you take a look at it?

@typicode
Copy link
Owner

Thank you!

@typicode typicode merged commit 6ca65ef into typicode:master Jul 14, 2017
@andys8
Copy link

andys8 commented Aug 2, 2017

@typicode Do you know when these changes will be released?

@typicode
Copy link
Owner

typicode commented Aug 2, 2017

@andys8 Thanks for the reminder, today :)

@typicode
Copy link
Owner

typicode commented Aug 2, 2017

Released 👍

@andys8
Copy link

andys8 commented Aug 3, 2017

Awesome, @typicode !

@crazy4groovy
Copy link

So to be clear, I'm using it in this way:

const middlewares = jsonServer.defaults({ bodyParser: true }); server.use(middlewares);

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

Successfully merging this pull request may close these issues.

4 participants