{
"errCode": -501007,
"errMsg": "wxacode.getUnlimited:fail missing wxCloudApiToken"
}
小程序通过HTTP方式 ,跨环境调用云函数,报出以上错误
偶尔一次会成功,大部分情况下均失败
//初始化方法
constructor(event = {}) {
cloud.init({ env: "bot-xxxxxxxxxxxx" });
this.cloud = cloud;
this.db = cloud.database({ throwOnNotFound: false });
this._ = this.db.command;
this.$ = this.db.command.aggregate;
this.wxContext = cloud.getWXContext();
this.now = new Date()
this.req = event.params
this.res = response
this.userInfo = event.userInfo
// this.log = cloud.logger()
}
//调用函数
async getQRcode() {
const { page, scene } = this.req
const cloud = this.cloud
try {
const res = await cloud.openapi({ appid: "wxe061111fb6f11d85" }).wxacode.getUnlimited({
'page': 'page',
'width': 400,
'scene': 'scene',
'line_color': {
"r": 0,
"g": 0,
"b": 0,
},
'env_version': "release", //扫描后打开的小程序的版本,正式版release,体验版trial,开发版develop
'check_path':false,
'auto_color': false,
'is_hyaline': false
})
return res.buffer.toString('base64');
} catch (err) {
console.error('错误信息', err)
return this.res.error('生成失败' + err, err)
}
}