【发布时间】:2022-06-10 19:03:43
【问题描述】:
如何使用 GitHub auth token 和 axios 授权https://api.github.com?
【问题讨论】:
标签: axios github-api bearer-token
如何使用 GitHub auth token 和 axios 授权https://api.github.com?
【问题讨论】:
标签: axios github-api bearer-token
const axiosInstance = axios.create({
baseURL: 'https://api.github.com',
headers: {
Authorization: 'Bearer AUTH_TOKEN_HERE'
}
});
let response = await axiosInstance.get('/');
【讨论】:
const fetchRepo = async () => { 常量响应 = 等待 axios.get(URL, { 方法:“获取”, 标题:{ '授权': 'Bearer AUTH_TOKEN_HERE', } }); console.log(等待响应); 返回响应。数据; }
【讨论】: