如何解决"TypeError: fn is not a function"?



我正试图在nodejs应用程序中实现Passport.JS和JWT功能,并收到以下错误

TypeError: fn is not a function

在我的应用程序的这个代码块中

const utils = require('./utils')
const strategies = require('./strategies')
const pipe = (...functions) => args => functions.reduce((arg, fn) => fn(arg), args)
const initialiseAuthentication = app => {
utils.setup()
pipe(strategies.JWTStrategy)(app)
}
module.exports = { utils, initialiseAuthentication, strategies }

如果有人能引导我朝着正确的方向前进,那就太棒了,因为我被困在这里。非常感谢。

自己发现了问题。在/strategies/index.js文件中,我像module.exports = { strategy }一样导出策略,但在代码片段中调用了pipe(strategies.JWTStrategy)(app)

必须是pipe(strategies.strategy)(app)

最新更新