POST body missing. Did you forget use body-parser middleware?
- Dominant language
- JavaScript
- Stars
- 2.3k
- Forks
- 88
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
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 ()
at IncomingMessage. (/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
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.