【问题标题】:How to authorize to GitHub API using axios如何使用 axios 授权给 GitHub API
【发布时间】:2022-06-10 19:03:43
【问题描述】:

如何使用 GitHub auth token 和 axios 授权https://api.github.com

【问题讨论】:

    标签: axios github-api bearer-token


    【解决方案1】:
    const axiosInstance = axios.create({
        baseURL: 'https://api.github.com',
        headers: {
            Authorization: 'Bearer AUTH_TOKEN_HERE'
        }
    });
    let response = await axiosInstance.get('/');
    

    【讨论】:

      【解决方案2】:

      const fetchRepo = async () => { 常量响应 = 等待 axios.get(URL, { 方法:“获取”, 标题:{ '授权': 'Bearer AUTH_TOKEN_HERE', } }); console.log(等待响应); 返回响应。数据; }

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-03-20
        • 1970-01-01
        • 1970-01-01
        • 2017-10-29
        • 2018-09-27
        • 2019-03-07
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多