Javascript 为什么Github';s GraphQL API 401与Axios兼容?
我试图使用Javascript 为什么Github';s GraphQL API 401与Axios兼容?,javascript,github,graphql,axios,Javascript,Github,Graphql,Axios,我试图使用axios获取github的graphQL端点,但它总是说我没有授权: const handleClick = token => event => axios.get("https://api.github.com/graphql", { headers: { "Authorization": "bearer" + token} }).then(response => console.log(response)) 我得到了这个错误: GET http
axios获取github的graphQL端点,但它总是说我没有授权:
const handleClick = token => event =>
axios.get("https://api.github.com/graphql", {
headers: { "Authorization": "bearer" + token}
}).then(response => console.log(response))
我得到了这个错误:
GET https://api.github.com/graphql 401 (Unauthorized)
bundle.js:1475 Uncaught (in promise) Error: Request failed with status code 401
at createError (bundle.js:1475)
at settle (bundle.js:1619)
at XMLHttpRequest.handleLoad (bundle.js:1028)
createError @ bundle.js:1475
settle @ bundle.js:1619
handleLoad @ bundle.js:1028
您需要在“持票人”和您的代币之间留一个空格:
"bearer " + token
您需要在“持票人”和您的代币之间留一个空格:
"bearer " + token