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.

1 Answer

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).

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like