【问题标题】:I am trying to create a authentication using passport js, but I am getting an error while passing a parameter (passport) in the router.get我正在尝试使用护照 js 创建身份验证,但是在 router.get 中传递参数(护照)时出现错误
【发布时间】:2021-09-05 16:29:48
【问题描述】:

这段代码只在一个文件中运行良好,我想将代码分成一个路由控制器文件。通过此 OAuth 护照身份验证时,出现错误。

//route.js code
router.get("/auth/google", [passport.authenticate("google", { scope: ["profile"] })], auth.googleGet);

//Error I am getting
Error: Route.get() requires a callback function but got a [object Undefined]

【问题讨论】:

    标签: node.js mongodb express mongoose passport.js


    【解决方案1】:

    router.get 需要一个回调函数,因为它是第二个参数。您正在向其中传递一个数组。这就是您收到错误消息的原因。

    【讨论】:

      猜你喜欢
      • 2022-06-16
      • 2015-09-13
      • 2017-09-17
      • 1970-01-01
      • 1970-01-01
      • 2018-05-02
      • 1970-01-01
      • 2016-10-19
      • 2016-10-22
      相关资源
      最近更新 更多