koa2 path data is correct or 404
and await is not allowed in the function. Without await, you can
router.prefix("/post")
router.get("/list",Post.list);
exports.list = async(ctx, next)=>{
let keyword,query,result=[];
if( ctx.query.keyword){
keyword = ctx.query.keyword;
query = Post.find({
$or:[{
title: /.*${keyword}.*/i,
body: /.*${keyword}.*/i
}]
},
"title category tags createAt updateAt _id");
}else{
query = Post.find({},"title category tags createAt updateAt _id");
}
result= await dbHelper.Exec(query);
console.log(`result:${result}`)//
ctx.body = result; // ctx.response.body = result;
console.log(ctx) //
}