已经解决:本地调试各种错误,云端测试直接成功了
index.js:52 CloudSDKError: errCode: -1 unknown error | errMsg: collection.add:fail Error:
400 Bad Request
; at collection.add api;
at returnAsCloudSDKError (C:\Users\Administrator\WeChatProjects\miniprogram-3\cloudfunctions\obj\node_modules\wx-server-sdk\index.js:6086:16)
at Object.returnAsFinalCloudSDKError (C:\Users\Administrator\WeChatProjects\miniprogram-3\cloudfunctions\obj\node_modules\wx-server-sdk\index.js:6100:15)
at Promise (C:\Users\Administrator\WeChatProjects\miniprogram-3\cloudfunctions\obj\node_modules\wx-server-sdk\index.js:1198:32)
at processTicksAndRejections (internal/process/task_queues.js:86:5)
代码如下
let db_temp = db.collection("objects")
for(let i in result.data){
let data_record = {
name: result.data[i].field_2,
abstract: result.data[i].field_4,
sex: result.data[i].field_5,
price: result.data[i].field_3,
players: result.data[i].field_1,
thumbnails: result.data[i].field_6,
serial_number: result.data[i].serial_number
}
console.log(data_record)
try{
return await db_temp.add({
data: data_record
})
} catch(e){
console.error(e)
}
}
需要先看console.log(data_record)的结果
现在是否正常?
传到服务器上就正常了
我也搞不懂了
db哪来的,请贴完整的云函数代码