static async loginBack(ctx) {
let code = ctx.query.code;
return new Promise((resolve, reject) => {
nwo.success(app, code, function(error, body) {
return body;
});
});
}
由于使用异步触发,无法返回执行结果
使用Promise 处理
static async loginBack(ctx) {
let code = ctx.query.code;
return new Promise((resolve, reject) => {
nwo.success(app, code, function(error, body) {
if (!error) {
// var accessToken = body.acess_token;
// var refreshToken = body.refresh_token;
// that.openid = body.openid;
resolve(body.openid);
}else{
reject(err);
}
});
});
}
可同步执行获取结果