直接上代码:
exports.main = async (event, context) => { const wxContext = cloud.getWXContext() var openid = wxContext.OPENID var myavatarUrl = event.avatarUrl var myavtivityid = event.avtivityid try { let userSignUpDatas = await db.collection( 'usersignupdb' ).add({ // data 字段表示需新增的 JSON 数据 data: { db_avtivityid: myavtivityid, db_openid: openid, db_avatarUrl: myavatarUrl }, success: function (res) { // res 是一个对象,其中有 _id 字段标记刚创建的记录的 id console.log( 'baomingactivity server success' , res) }, fail: function (err){ console.log( 'baomingactivity server fail' , err) }, complete: function (res){ console.log( 'baomingactivity server complete' , res) } }) console.log( 'baomingactivity userSignUpDatas1' , userSignUpDatas) } catch (e) { console.error(e) console.log( 'baomingactivity server catch err' , e) return e } } |
我在调用此函数的的时候,在云函数日志中,只输出:
console.log( 'baomingactivity userSignUpDatas1' , userSignUpDatas) |
对应的success,fail 和 complete 日志 却没有,请问大家遇到过吗?
await里还有success?