微信小程序云开发先数据库添加数据不成功,这是为啥?
云函数代码:
const cloud = require('wx-server-sdk')
cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV }) // 使用当前云环境
// 云函数入口函数
exports.main = async (event, context) => {
await cloud.database().collection("data").add({
data: {
imageUrl: event.imageUrl,
imageNumber: event.imageNumber,
page: event.page,
address: event.address,
expression: event.expression,
phonenumber: event.phonenumber,
view: event.view,
index: event.index,
date: event.date
}
}).then(res=>{
console.log("成功上传", res)
})
}
调用js的代码:
uploadData(){
wx.cloud.callFunction({
name:"upData",
data:{
imageUrl:this.imageUrl,
imageNumber:this.imageNumber,
page:this.page,
address:this.address,
expression:this.expression,
phonenumber:this.phonenumber,
view:this.view,
index:this.index,
date:this.date
}
}).then(res=>{
console.log("云函数调用成功")
})
}