- 云函数返回的对象的属性不能访问
xd(){wx.cloud.init({env:"jh001-9gryplec55e9efeb"}); let {order}={...this.data}; order.orderId=new Date().getTime(); console.log({"name":"订单"}.name); wx.cloud.callFunction({ name:"get_xd", data:{order:order} }).then(res=>console.log(res))} //以上是小程序中的代码 //以下是云函数部分代码 try { let result= cloud.openapi.logistics.addOrder(order); /* return result; 云函数返回给小程序的数据 result: {orderId: "1690084690185", waybillId: "1690084690185_waybill_id", deliveryResultcode: 0,。。。。。 */ await db.collection('order').add({ data:{ orderId:result.orderId, //为何result的对象属性访问不到 waybillId:result.waybillId //为何result的对象属性访问不到 } }).then(res=>res).catch(console.log(err)) } catch (err) { return err }
2023-07-23 - 申请单次分账出错?
// 云函数入口文件 const cloud = require('wx-server-sdk') cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV }) // 云函数入口函数 exports.main = async (event, context) => { const wxContext = cloud.getWXContext(); const receivers=JSON.stringify( [{ "type": "MERCHANT_ID", "account":"1607xxxxx", "amount":20, "description": "分到商户" , }]) const res= await cloud.CloudPay.profitSharing({ sub_mch_id:"160853xxx", nonce_str:"5K8264ILTKCH16CQ2502SI8ZNMTM67VS", transaction_id:event.transactionId, out_order_no:event.outTradeNo, receivers:receivers }); return res; } VM342 WAService.js:2 Error: cloud.callFunction:fail Error: errCode: -504002 functions execute fail | errMsg: TypeError: Cannot read property 'profitSharing' of undefined at Runtime.exports.main [as handler] (:61536/var/user/index.js:20) at Runtime.handleOnce (:61536/var/runtime/node12/Runtime.engine.js:219) at Timeout._onTimeout (:61536/var/runtime/node12/Runtime.engine.js:56) at listOnTimeout (:61536/appservice/internal/timers.js:549) at processTimers (:61536/appservice/internal/timers.js:492) (callId: 1644667719936-0.8142589655852928) (trace: 20:8:39 start->20:8:40 system error (Error: errCode: -504002 functions execute fail | errMsg: TypeError: Cannot read property 'profitSharing' of undefined at Runtime.exports.main [as handler] (:61536/var/user/index.js:20) at Runtime.handleOnce (:61536/var/runtime/node12/Runtime.engine.js:219) at Timeout._onTimeout (:61536/var/runtime/node12/Runtime.engine.js:56) at listOnTimeout (:61536/appservice/internal/timers.js:549) at processTimers (:61536/appservice/internal/timers.js:492)), abort) at I (VM342 WAService.js:2) at VM342 WAService.js:2(env: Windows,mp,1.05.2201240; lib: 2.16.0) errorReport @ VM342 WAService.js:2 thirdErrorReport @ VM342 WAService.js:2 (anonymous) @ VM342 WAService.js:2 I @ VM342 WAService.js:2 o @ VM342 WAService.js:2 (anonymous) @ VM342 WAService.js:2 value @ VM342 WAService.js:2 o @ VM342 WAService.js:2 (anonymous) @ VM342 WAService.js:2
2022-02-12