Skip to content

Update README.md example since var token is already defined #454

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

Closed
joshunger opened this issue Mar 11, 2018 · 5 comments
Closed

Update README.md example since var token is already defined #454

joshunger opened this issue Mar 11, 2018 · 5 comments
Assignees

Comments

@joshunger
Copy link
Contributor

I copy and pasted the example

// sign with default (HMAC SHA256)
var jwt = require('jsonwebtoken');
var token = jwt.sign({ foo: 'bar' }, 'shhhhh');
//backdate a jwt 30 seconds
var older_token = jwt.sign({ foo: 'bar', iat: Math.floor(Date.now() / 1000) - 30 }, 'shhhhh');

// sign with RSA SHA256
var cert = fs.readFileSync('private.key');  // get private key
var token = jwt.sign({ foo: 'bar' }, cert, { algorithm: 'RS256'});

// sign asynchronously
jwt.sign({ foo: 'bar' }, cert, { algorithm: 'RS256' }, function(err, token) {
  console.log(token);
});

And noticed an error since var token is already defined. Do you want me to send you a PR to update the example code? Can we use const?

@ziluvatar
Copy link
Contributor

Good catch. Yes, be free to open a PR with the change, you can choose, to fix the problem or to fix + use const.

@joshunger
Copy link
Contributor Author

@ziluvatar can you assign the issue to me? Do you care how I fix it? Thanks.

@ziluvatar
Copy link
Contributor

ziluvatar commented Apr 8, 2018

Done. You choose the way, I'll review the PR afterwards anyway.

@joshunger
Copy link
Contributor Author

joshunger commented Apr 18, 2018

See PR #461

@ziluvatar
Copy link
Contributor

Thanks @joshunger , merged!

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

2 participants