Skip to content

Instantly share code, notes, and snippets.

@davidbarral
Created January 20, 2018 15:44
Show Gist options
  • Save davidbarral/6678d895b82207128ab024c9d160e947 to your computer and use it in GitHub Desktop.
Save davidbarral/6678d895b82207128ab024c9d160e947 to your computer and use it in GitHub Desktop.
Promisify: initial code
const jwt = require("jsonwebtoken");
const verifyToken = token => new Promise((resolve, reject) => {
jwt.verify(token, CERTIFICATE, { algorithms: ["RS256"] }, (error, payload) => {
if (error) {
reject(error);
} else {
resolve(payload);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment