T
T
Tynkute2020-07-10 21:00:31
JSON Web Token
Tynkute, 2020-07-10 21:00:31

Node error: {function} is not a function?

This function is defined in the generateJWTAccessToken file :

const jwt = require('jsonwebtoken');

module.exports  = function generateJWTAccessToken(data, time = '6h', algo = 'HS256', secret){
       return  jwt.sign({data,}, secret, {expiresIn:time , algorithm:algo});
}

This is where the function is used:
const {generateJWTAccessToken} = require('../tokensJwt/generateJwtToken');

const jwtAccessToken =  generateJWTAccessToken(user.email, "7h", "HS256",  secret.secretWordJwtAccess);
res.status(200).json({message:`welcome back ${req.body.login}, ${jwtAccessToken}`});

Gives an error: TypeError: generateJWTAccessToken is not a function
What's the problem here?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Loli E1ON, 2020-07-10
@Tynkute

const generateJWTAccessToken = require('../tokensJwt/generateJwtToken');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question