Skip to content
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

JSON parse error when using OAuth token #35

Open
rajinder-yadav opened this issue May 4, 2019 · 1 comment
Open

JSON parse error when using OAuth token #35

rajinder-yadav opened this issue May 4, 2019 · 1 comment

Comments

@rajinder-yadav
Copy link

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
Copy link
Author

You can generate your token here: https://github.com/settings/tokens

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant