POST body missing. Did you forget use body-parser middleware?
See original GitHub issueHi,
Has anyone faced this issue
POST body missing. Did you forget use body-parser middleware?
SyntaxError: Unexpected token P in JSON at position 0
at JSON.parse (<anonymous>)
at IncomingMessage.<anonymous> (/home/abc/server/node_modules/graphql.js/graphql.js:71:25)
this is my code
const query = graph(`mutation(
$username: String!,
$password: String! ) {
authentication {
login(
username: $username,
password: $password,
strategy: "local"
) {
responseResult {
succeeded
errorCode
message
}
jwt
}
}
}`);
query({
username: req.body.username,
password: req.body.password
}).then(
resData => {
res.send(resData);
},
err => {
console.error(err)
res.status(500).send(err)
}
);
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
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
node.js - GraphQL - POST body missing. Did you forget use ...
I have tried different recommendations with body-parser online, but still can't seem to fix it. Server: require('babel-polyfill') const express ...
Read more >POST body missing. Did you forget use body-parser ... - GitHub
I used graphql and koa2. const Koa = require('koa') const json = require('koa-json') const bodyparser = require('koa-bodyparser') const ...
Read more >Why I getting this error: POST body missing. Did you forget ...
I am trying to upload a file to the server using apollo-server-fastify. I didn't use the fastify-multipart or similar dependencies because ...
Read more >POST body missing. Did you forget use body-parser ...
Did you forget use body-parser mpoatiddleware? Hi , I already update my katalon to 5.8 , but when I runned my graphQL script...
Read more >GRANDstack starter - Using Postman API to get data... - Neo4j
... 'POST body missing. Did you forget use body-parser middleware?'. Does somebody has an idea how to get Postman working with GraphQL? I ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hey!
Can you test is by passing
asJSON: true?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.