代码之家  ›  专栏  ›  技术社区  ›  chichi

节点控制器不是函数

  •  0
  • chichi  · 技术社区  · 4 年前

    我有快速应用程序路线控制器服务。当我尝试get请求时,我得到了一个错误。

    /路线

    router.get('/check', (...args) => ProfileCheckController.profileCheck(...args));
    

    class ProfileCheckController {
      static async profileCheck(req, res) {
        console.log(req);
        const { errors, isValid } = await validateProfileCheck(
          JSON.parse(req.body.email)
        );
    
        if (!isValid) {
          return res.state(400).json(errors);
        }
        const profileChecked = await ProfileCheckService.checkProfile(
          JSON.parse(req.body.email)
        );
        res.send(profileChecked);
      }
    }
    

    /服务

    class ProfileCheckService {
      static async checkProfile(email) {
        try {
          const profile = await Profile.findOne(email);
          return profile;
        } catch (err) {
          return console.log(err);
        }
      }
    }
    

    基本上,我试图搜索一个用户配置文件,我试图发送它从需求主体但是,我也尝试使用params。上一次当我遇到“not a function”错误时,我忘了输入“static”,这是我检查的第一件事。为什么公关ofileCheckController.profilecheck文件不是函数吗?

    0 回复  |  直到 4 年前