环境共享,被共享方如何使用云函数?
https://developers.weixin.qq.com/miniprogram/dev/wxcloud/guide/resource-sharing/ 我在调用方增加了云函数cloudbase_auth 。 使用时报错Error: errCode: -404011 cloud function execution error | errMsg: cloud.callFunction:fail requestID , cloud function service error code -501000, error message [100003] env not exists (9408d88d-a437-4a25-bc97-4feaf2724a2d); at cloud.callFunction api; 如果按照下面这样写 ,就报错 appservice 生成错误] miniprogram/app.js: file: app.js unknown: Unexpected reserved word 'await'. (31:0) 29 | // 跨账号调用,必须等待 init 完成 30 | // init 过程中,资源方小程序对应环境下的 cloudbase_auth 函数会被调用,并需返回协议字段(见下)来确认允许访问、并可自定义安全规则 > 31 | await c1.init() | ^ 32 | 33 | } 34 | c1.callFunction({ // app.js App({ onLaunch: function () { if (!wx.cloud) { console.error('请使用 2.2.3 或以上的基础库以使用云能力'); } else { // wx.cloud.init({ // // env 参数说明: // // env 参数决定接下来小程序发起的云开发调用(wx.cloud.xxx)会默认请求到哪个云环境的资源 // // 此处请填入环境 ID, 环境 ID 可打开云控制台查看 // // 如不填则使用默认环境(第一个创建的环境) // env: 'cloud1-8guv4660c1c70c65', // resourceEnv: 'cloud1-8guv4660c1c70c65', // traceUser: true, // }); //const newcloud = new wx.cloud.Cloud({ // resourceEnv: 'cloud1-8guv4660c1c70c65', // traceUser: true, //}) //newcloud.init() // 声明新的 cloud 实例 var c1 = new wx.cloud.Cloud({ // 资源方 AppID resourceAppid: 'wxe0e2656d74f0bff3', // 资源方环境 ID resourceEnv: 'test-f96b31', }) // 跨账号调用,必须等待 init 完成 // init 过程中,资源方小程序对应环境下的 cloudbase_auth 函数会被调用,并需返回协议字段(见下)来确认允许访问、并可自定义安全规则 await c1.init() } c1.callFunction({ name: 'quickstartFunctions', //config: { // env: this.data.envId //}, data: { type: 'getOpenId' } }).then((resp) => { this.globalData.openId = resp.result.openid; }).catch((e) => { this.setData({ showUploadTip: true }); wx.hideLoading(); }); this.globalData = { suffix:'000000' }; } });