Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"undefined is not a function" on jwt.sign #48

Closed
OKNoah opened this issue Jan 14, 2015 · 8 comments
Closed

"undefined is not a function" on jwt.sign #48

OKNoah opened this issue Jan 14, 2015 · 8 comments

Comments

@OKNoah
Copy link

OKNoah commented Jan 14, 2015

Code:

jwt = require('express-jwt'),
var token = jwt.sign( { id: user._id }, secret.secretToken, { expireInMinutes: tokenManager.TOKEN_EXPIRATION } )

Error:

        var token = jwt.sign( { id: user._id }, secret.secretToken, { expireInMinut
                        ^
TypeError: undefined is not a function
@jfromaniello
Copy link
Member

This module is used only to validate/decode jwts on express.js requests.

If you need to sign requests you need to use https://github.com/auth0/node-jsonwebtoken

If there is a bit of documentation causing this confusion, please feel free to submit a pr.

@darekrossman
Copy link

Seems you could just as easily export the sign method from the already included jsonwebtoken module so that this module could provide that, no?

@cgarvis
Copy link

cgarvis commented Sep 18, 2015

+1

1 similar comment
@liam-betsworth
Copy link

+1

@acushlakoncept
Copy link

This fix the issue for me.
const { expressjwt: jwt } = require("express-jwt");

@jaerperez
Copy link

thanks @acushlakoncept great solution! it's working for me

@Benja1512
Copy link

+1

@Jay-study-nildana
Copy link

Jay-study-nildana commented Jan 24, 2023

@acushlakoncept

This fixes my issue as well, but, why is this not already in the documentation :(

Update : So, it is mentioned in the official sample. ah. i see what happened there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants