-
-
Notifications
You must be signed in to change notification settings - Fork 89
Open
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 (<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
sosonami2
Metadata
Metadata
Assignees
Labels
No labels