回调失败,即使生成了GitHub安装访问令牌

时间:2018-12-11 20:50:23

标签: javascript node.js github github-api referenceerror

我具有用于生成安装访问令牌的以下代码:

<div class="jumbotron jumbotron-fluid-flex text-white mb-0 rounded-0">
  <div class="container-fluid py-5">
    <div class="row d-flex justify-content-center justify-content-lg-left">
      <div class="col-sm-12 text-center col-md-9 text-lg-left col-lg-8 pl-lg-3 align-self-center bg-warning">
        <h1 class="text-dark">My column content</h1>
      </div>
    </div>
  </div>
</div>

它输出gitInstallationAccessToken.getAccessTokensUrl(jwt, function(appAccessTokensUrl) { var instance = axios({ method: "POST", url: appAccessTokensUrl, headers: { "Accept" : "application/vnd.github.machine-man-preview+json", "Authorization" : `Bearer ${jwt}` } }) .then(function(response) { var installationAccessToken = response.data.token; console.log(`Installation Access Token: ${installationAccessToken}`) callback(installationAccessToken); }) .catch(function(error) { console.warn("Unable to authenticate"); // The request was made and the server responded with a status code // that falls out of the range of 2xx if (error.response) { console.warn(`Status ${error.response.status}`); console.warn(`${error.response.data.message}`); } }); }); ,因此在某些时候失败。我的问题是Unable to authenticate输出一个令牌,因此我希望回调能够成功。有什么可能会导致失败的原因吗?

其他信息

这是在catch中返回的实际错误:

console.log('Installation Access Token: ${installationAccessToken}')

类似的情况可能与this的解决方案2有关。我不确定最后两个步骤在哪里。

1 个答案:

答案 0 :(得分:0)

我安装了class Feline { public String type = "f "; public Feline() { System.out.print("feline "); } } class Cougar extends Feline { public Cougar() { System.out.print("cougar "); } void go() { type = "c "; System.out.print(this.type + super.type); } public static void main(String[] args) { new Cougar().go(); } } 并将babel-plugin-transform-regenerator添加到问题文件的顶部。似乎已经解决了该问题,尽管对我而言这真的没有意义。