为什么 Github 的 GraphQL API 401ing 与 Axios?

Why is Github's GraphQL API 401ing with Axios?

我正在尝试使用 axios GET 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" 和您的令牌之间添加一个 space:

"bearer " + token