JSON parse error when using OAuth token
rajinder-yadav opened this issue · comments
Rajinder Yadav commented
I've got this to work using Postman, however the following code generates a JSON parse error?
Code
const graphql = require('graphql.js');
const graph = graphql('https://api.github.com/graphql', {
method: "POST",
headers: {
"User-Agent": "node",
"Authorization": "Bearer <github-token>"
}
});
const query = graph(`query { viewer { login name } }`);
query().then(
res => console.log(JSON.stringify(res)),
err => console.error(err)
);
Error
{ message: 'Problems parsing JSON',
documentation_url: 'https://developer.github.com/v4' }
Rajinder Yadav commented
You can generate your token here: https://github.com/settings/tokens