- 云函数中调用另一个云函数(获取mqtt的函数)提示缺少参数,错误码-504002?
基础库版本:2.19.2 这个获取mqtt数据的函数是可以在小程序中调用的,当时就是直接传入了全局参数,现在调用就不行了。 // 函数调用 addOrderData:function(event){ console.log(event); console.log('SecretId: ', app.globalData.secretId); wx.cloud.callFunction({ name:'addOrderData', data: { ProductId: app.globalData.productId, DeviceName: app.globalData.deviceName, SecretId: app.globalData.secretId, // 全局变量 SecretKey: app.globalData.secretKey, } }).then(res => { console.log(res) }) } // 云函数入口文件 const cloud = require('wx-server-sdk') cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV }) // 使用当前云环境 const db = cloud.database() const dishesCollection = db.collection('dishes') const orderCollection = db.collection('order') // 云函数入口函数 exports.main = async (event, context) => { const { productId, deviceName, secretId, secretKey } = event; console.log(productId, deviceName, secretId, secretKey); // 获取云端数据 const mqttData = await cloud.callFunction({ name: 'iothub-shadow-query', data: { ProductId: productId, DeviceName: deviceName, SecretId: secretId, // 这里提示The request is missing a required parameter 'SecretID' SecretKey: secretKey, } }); let payload = JSON.parse(mqttData.result.Data); // 获取最新order和_id const latestOrder = await orderCollection .orderBy('_id', 'desc') // 根据_id(创建时间)降序排序 .limit(1) // 只取一条数据 .get(); // 获取数据 const latestOrderId = latestOrder.data[0]._id; // 保存最新订单的 _id console.log(latestOrderId); // 数据预处理 let dishes = {}; // 遍历 payload.state.reported.order for (let i = 0; i < payload.state.reported.order.length; i++) { // 使用 `dishes_{num}` 作为键,stateReported.order[i] 作为值 dishes[`dishes_${i+1}`] = payload.state.reported.order[i]; } return await orderCollection.add({ data: { _id: latestOrderId + 1, ...dishes // 使用展开语法将 dishes 对象的所有键-值对添加到 data 对象中 } }) } // 报错: Error: cloud.callFunction:fail Error: errCode: -504002 functions execute fail | errMsg: Error: callFunction:fail -504002 functions execute fail. requestID 1689611537027_0.04395270231172965_33592712-18964b20ddc_1, Error: The request is missing a required parameter `SecretId`. at IotcloudClient.parseResponse (:45770/var/user/node_modules/tencentcloud-sdk-nodejs/tencentcloud/common/abstract_client.js:138) at processTicksAndRejections (:45770/appservice/internal/process/task_queues.js:97) at async IotcloudClient.doRequest (:45770/var/user/node_modules/tencentcloud-sdk-nodejs/tencentcloud/common/abstract_client.js:100) at toSDKError (:45770/var/user/node_modules/wx-server-sdk/index.js:8094) at Object.returnAsFinalCloudSDKError (:45770/var/user/node_modules/wx-server-sdk/index.js:8065) at :45770/var/user/node_modules/wx-server-sdk/index.js:1756 at processTicksAndRejections (:45770/appservice/internal/process/task_queues.js:97) (callId: 1689611537026-0.7871532857882892) (trace: 0:32:17 start->0:32:18 system error (Error: errCode: -504002 functions execute fail | errMsg: Error: callFunction:fail -504002 functions execute fail. requestID 1689611537027_0.04395270231172965_33592712-18964b20ddc_1, Error: The request is missing a required parameter `SecretId`. at IotcloudClient.parseResponse (:45770/var/user/node_modules/tencentcloud-sdk-nodejs/tencentcloud/common/abstract_client.js:138) at processTicksAndRejections (:45770/appservice/internal/process/task_queues.js:97) at async IotcloudClient.doRequest (:45770/var/user/node_modules/tencentcloud-sdk-nodejs/tencentcloud/common/abstract_client.js:100) at toSDKError (:45770/var/user/node_modules/wx-server-sdk/index.js:8094) at Object.returnAsFinalCloudSDKError (:45770/var/user/node_modules/wx-server-sdk/index.js:8065) at :45770/var/user/node_modules/wx-server-sdk/index.js:1756 at processTicksAndRejections (:45770/appservice/internal/process/task_queues.js:97)), abort) at Ht (WASubContext.js?t=wechat&s=1689601822686&v=2.19.2:2) at WASubContext.js?t=wechat&s=1689601822686&v=2.19.2:2(env: macOS,mp,1.06.2306020; lib: 2.19.2)
2023-07-17 - 新版图片文章在草稿箱中编辑时内容丢失?
【公众号】: UESTC拾光摄影 【浏览器UA】: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.3 Safari/605.1.15 【页面链接】: https://mp.weixin.qq.com/cgi-bin/appmsg?t=media/appmsg_edit&action=edit&type=77&appmsgid=100000266&isMul=1&replaceScene=0&isSend=0&isFreePublish=0&token=1857070874&lang=zh_CN 【问题描述】: [图片][图片]
2023-03-17