-
-
Notifications
You must be signed in to change notification settings - Fork 87
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
POST body missing. Did you forget use body-parser middleware? #58
Comments
Hi @mrkhan, i'm running into the same error. I'm quite new to GraphQL and this library. But i'm trying to learn how it all works with this free GraphQL API here - https://countries.trevorblades.com/ I've made a JSfiddle which reproduces the error - https://jsfiddle.net/21f75w9e/9/ . I hope someone can help! |
Hey! Can you test is by passing const graphTest = graphql("https://countries.trevorblades.com/", {
method: "POST",
asJSON: true
}); |
Thanks @f , that did the trick, in my example! What exactly does that parameter do? I'm reading the README and I'm still a bit confused.
|
It converts Form data to JSON body. Normally it sends data as form values. If you're using a back-end which uses JSON body it may break. |
gotcha, thanks for clarifying. sorry for hijacking your issue @mrkhan! |
In my case, my client don't directly query graphql server. I am able to read each values (username, password) in my node server which then fires query to Graphql. |
yo what godd yall |
Merry Christmas yall |
Hi,
Has anyone faced this issue
this is my code
am running graphql.js in express server and not using 'body-parser' but rather uses
express.json()
. I am sure that I am able to read 'req.body.username' and 'req.body.password' values successfully, so why is it suggesting to use body-parser ?Weird thing is this request runs fine on my local machine but gives this error on deployed server.
Could someone let me know, how to console.log body, before we query?
Regards
The text was updated successfully, but these errors were encountered: