I want to get all branch name in my private repo via github api. It's success when I use cli, but i get error code 404 when i use axios in react app. I'm sure that my url and token is correct in both cli and react app. By the way, my react app can successfully get public repo branch name but not include private.
my Js code
const owner = 'Solo-steven';
const token = MYTOKEN;
const repo = 'Sideex-private-test'
async function getPrivateBranchName(){
await axios({
method: 'get',
url : `https://api.github.com/repos/${owner}/${repo}/branches`,
header:{
Authorization: `token ${token}`
}
}).then(response=>{
console.log(response, `Success get all branch name of repo(${repo}).`)
}).catch(response=>{
console.log(response, `error when get branch name of repo(${repo})`);
})
}
my Cli
curl -H "Authorization: token MYTOKEN" https://api.github.com/repos/Solo-steven/Sideex-private-test/branches
According to https://www.npmjs.com/package/axios it is headers not header
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.