2017-06-17 93 views
0

我試圖Get GitHub的graphQL端點使用axios和它不斷包圍我,說我沒有通過認證:爲什麼Github的GraphQL API 401與Axios?

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 

回答

1

您需要「持票人」和您的令牌之間的空間:

"bearer " + token 
相關問題