TypeError: expressJwt is not a function, using a middleware

I am learning to use middlewares and as I am trying to import express-jwt it does not work. I am using the following syntax: const expressJwt = require('express-jwt')

I uninstalled express-jwt and installed an older version [email protected], in which it works, but I wanna know how to fix it on the new version.

Upvotes: 0

Views: 615

Answers (2)

benjamin ontiveros
benjamin ontiveros

Reputation: 15

//protection API and Authentication JWT middleware

const expressJwt = require('express-jwt')

function authJwt() {
    const secret = process.env.secret;

    function expressJwt(param) {
        return undefined;
    }
have the same problem


    return expressJwt({
      secret,
       algorithms: ['HS256']
  })
 }

 module.exports = authJwt;

enter image description here

Upvotes: 0

NeNaD
NeNaD

Reputation: 20304

Try this:

const { expressjwt } = require("express-jwt");

Official docs

Upvotes: 1

Related Questions