var Token;
componentDidMount() {
auth0.webAuth.authorize({
scope: 'openid profile email',
audience: 'https://MyDomain/userinfo'
})
.then(credentials =>
console.log(credentials.accessToken))
this.key=credentials.accessToken;
}
答案 0 :(得分:0)
从ComponentDidMount看来这是个反应。
您似乎不是在回调内部执行this.key=credentials.accessToken
,而是在外部执行。这意味着当您尝试设置this.key = credentials.accessToken;
答案 1 :(得分:0)
尝试一下
var Token;
componentDidMount() {
auth0.webAuth.authorize({
scope: 'openid profile email',
audience: 'https://MyDomain/userinfo'
})
.then(credentials => {
console.log(credentials.accessToken);
this.key=credentials.accessToken });
}