【现象】
2022-01-17 18:32:26,958 ERROR 18500 [-/::1/-/1ms GET /findOne/1] nodejs.ReferenceError: ctx is not defined
at HomeController.findOne (..\showcase\app\controller\home.js:18:22)
at Object.callFn (..\showcase\node_modules\egg-core\lib\utils\index.js:44:21)
at Object.classControllerMiddleware (..\showcase\node_modules\egg-core\lib\loader\mixin\controller.js:87:20)
at Object.callFn (..\showcase\node_modules\@eggjs\router\lib\utils.js:12:21)
解决方法:
const user = await ctx.service.user.find({id:id});
修改为:
const user = await this.ctx.service.user.find({id:id});
版权说明 : 本文为转载文章, 版权归原作者所有 版权申明
原文链接 : https://onefire.blog.csdn.net/article/details/122546469
内容来源于网络,如有侵权,请联系作者删除!