[英]callback failing even though GitHub Installation access Token gets generated
I have this code for generating an Installation Access Token: 我具有用于生成安装访问令牌的以下代码:
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}`);
}
});
});
It outputs Unable to authenticate
so is failing at some point. 它输出Unable to authenticate
因此在某些时候失败。 My issue is that console.log('Installation Access Token: ${installationAccessToken}')
outputs a token so I would expect the callback to succeed. 我的问题是console.log('Installation Access Token: ${installationAccessToken}')
输出令牌,因此我希望回调能够成功。 Is there any reason why it's likely to fail? 是否有任何可能导致失败的原因?
Additional info 附加信息
This is the actual error returned in the catch: 这是在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)
Looks like this might relate to Solution 2 of this . 看起来这可能涉及到的解决方案2 本 。 I'm not sure where the last two steps would go though. 我不确定最后两个步骤在哪里。
I installed babel-plugin-transform-regenerator
and added import 'babel-polyfill'
to the top of the problem file. 我安装了babel-plugin-transform-regenerator
并将import 'babel-polyfill'
到问题文件的顶部。 Seems to have resolved the issue although it doesn't really make sense to me. 似乎已经解决了该问题,尽管对我而言这确实没有意义。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.