Skip to content

Instantly share code, notes, and snippets.

@zoutepopcorn
Last active May 24, 2018 06:29
Show Gist options
  • Save zoutepopcorn/fce6537d11c9889ff2ab97e0886dfbe8 to your computer and use it in GitHub Desktop.
Save zoutepopcorn/fce6537d11c9889ff2ab97e0886dfbe8 to your computer and use it in GitHub Desktop.
const jwt = require('jsonwebtoken');
const s = require('signale');
const token = jwt.sign({
user: 'johan'
}, 'aaaaa', {
expiresIn: '2s'
});
s.time('expires');
const getToken = () => {
jwt.verify(token, 'aaaaa', function(err, decoded) {
s.timeEnd('expires');
if (err) {
s.error(err.message);
} else {
s.success(decoded)
console.log(decoded);
}
});
}
setTimeout(() => {
getToken()
}, Math.random() * 1800);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment