直接贴代码,这是云函数端的代码
app.router('detail', async(ctx,next)=>{
let blogId = event.blogId //从云数据库中取到对应博客信息
//详情查询
let detail = await blogCollection.where({
_id:blogId
}).get().then((res)=>{
return res.data //获取到的博客数据储存在data中
})
//评论查询
const countResult = await blogCollection.count() //查询共有多少条数据
const total = countResult.total
let commentList ={
data:[]
}
if(total > 0){
const batchTimes = Math.ceil(total/ MAX_LIMIT) //要查询的次数,ceil为向上取整
const tasks = []
for(let i = 0;i<batchTimes;i++){
let promise = blogCollection.skip(i * MAX_LIMIT)
.limit(MAX_LIMIT).where({
blogId //要查询的索引为博客ID
}).orderBy('createTime' , 'desc').get() //通过get得到想要的结果
tasks.push(promise)
}
if(tasks.length > 0){
commentList = (await Promise.all(tasks)).reduce((acc,cur) => {
return {
data:acc.data.concat(cur.data)
}
})
}
}
ctx.body = { //将获取到的信息返回到前台
commentList,
detail,
}
})
这是调用端的函数
onLoad: function (options) {
console.log(options)
this._getBlogDetail(options.blogId)
},
_getBlogDetail(blogId){
wx.showLoading({
title: '加载中',
mask:true,
})
wx.cloud.callFunction({
name:'blog',
data:{
blogId,
$url:'detail',
}
}).then((res) => {
wx.hideLoading()
console.log(res)
})
},
报错:Error: errCode: -404011 cloud function execution error | errMsg: cloud.callFunction:fail requestID 72f99dfd-8850-11ea-9985-525400f6258f, cloud function service error code -504002, error message missing ) after argument list; at cloud.callFunction api
请问这是什么错误引起的呢?望指导一下!