[英]callback failing even though GitHub Installation access Token gets generated
我具有用于生成安装访问令牌的以下代码:
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
因此在某些时候失败。 我的问题是console.log('Installation Access Token: ${installationAccessToken}')
输出令牌,因此我希望回调能够成功。 是否有任何可能导致失败的原因?
附加信息
这是在catch中返回的实际错误:
ReferenceError: regeneratorRuntime is not defined
at eval (webpack:///./lib/githubService.js?:17:51)
at Object.retrieveIssues (webpack:///./lib/githubService.js?:87:6)
at eval (webpack:///./lib/getPublicGitHubIssues.js?:78:20)
at eval (webpack:///./lib/gitInstallationAccessToken.js?:84:9)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
看起来这可能涉及到的解决方案2 本 。 我不确定最后两个步骤在哪里。
我安装了babel-plugin-transform-regenerator
并将import 'babel-polyfill'
到问题文件的顶部。 似乎已经解决了该问题,尽管对我而言这确实没有意义。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.