gpt4 book ai didi

nodejs.ReferenceError: ctx is not defined解决方法

转载 作者:知者 更新时间:2024-03-13 09:23:28 31 4
gpt4 key购买 nike

【现象】

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}); 

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com