'How to solve "TypeError: fn is not a function"?
I'm trying to implement Passport.JS and JWT functionality into my nodejs application and receive the following error
TypeError: fn is not a function
in this code block of my application
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 }
Would be awesome if someone could guide me in the right direction, as I am stuck here. Thank you a lot.
Solution 1:[1]
Found the issue myself. In the /strategies/index.js file I was exporting the strategy like so module.exports = { strategy }, but was calling pipe(strategies.JWTStrategy)(app) in the code snippet.
It has to be pipe(strategies.strategy)(app).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | paaax |
