Why does this fetch return this error?

0

This is my fetch

   var code = this.props.location.query.code
fetch ('https://github.com/login/oauth/access_token/?client_id=xxxx&client_secret=xxxxx&code='+code+'&accept=json', {
    method: 'GET',
  })

Error

Fetch API cannot load https://github.com/login/oauth/access_token/?client_id=xxx&client_secret=xxx&code=c48c0c8d5a01db2f6fc6&accept=json. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://5e9d9e3b.ngrok.io' is therefore not allowed access. The response had HTTP status code 404. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

I'm trying to login with Oauth from GitHub, then when I return the code, I'll do another fetch to return it by answer json the user's acces_token which I'll store in localStorage , so I can work with the.

    
asked by Santiago D'Antuoni 23.01.2017 в 22:40
source

0 answers