const cloud = require('wx-server-sdk')
cloud.init()
const db = cloud.database()
// 云函数入口函数
exports.main = async (event, context) => {
const wxContext = cloud.getWXContext()
const user = wxContext.OPENID,
const productList = event.list || [],
await db.collection('order').add({
data: {
user,
createTime: +new Date(),
productList,
},
})
return {}
}
我遇到了这个问题,向云数据库上传订单,第一次显示上传成功,但是云数据库里没有订单记录。再次编译,就报错。错误如下:
VM2518:1 Error: errCode: -404011 cloud function execution error | errMsg: cloud.callFunction:fail requestID 8968010e-5982-11ea-af5f-525400e4521d, cloud function service error code -504002, error message Unexpected token try; at cloud.callFunction api;
at new u (WAService.js:1)
at d (WAService.js:1)
at f (WAService.js:1)
at Function.success (WAService.js:1)
at WAService.js:1
at C (WAService.js:1)
at i.<anonymous> (WAService.js:1)
at i.emit (WAService.js:1)
at Rs (WAService.js:1)
at WAService.js:1