Arpita Chaudhari
Arpita Chaudhari

Reputation: 1

I am having a problem while creating a token in NodeJS. Is there any solution please?

I want to generate token in nodejs where i can authenticate the user.

const expressjwt = require('express-jwt');

function authJwt() {
  const secret = process.env.secret;
  return expressjwt({ secret, algorithms: ['HS256'] });
}

module.exports = authJwt;

server.js file:

const authJwt = require('./helpers/jwt');
app.use(authJwt); 

I have tried to call authJwt() as well but its not working. Is there any solution or am i doing anything wrong? I am getting this error "TypeError: expressjwt is not a function".

Upvotes: 0

Views: 22

Answers (0)

Related Questions