Skip to content

Instantly share code, notes, and snippets.

@jmarmolejos
Created October 18, 2017 17:41
Show Gist options
  • Save jmarmolejos/7c64a5b55f7945c7fd48c5c08873ed15 to your computer and use it in GitHub Desktop.
Save jmarmolejos/7c64a5b55f7945c7fd48c5c08873ed15 to your computer and use it in GitHub Desktop.
function parseJwt (token) {
var payload = token.split('.')[1];
var base64 = payoad.replace('-', '+').replace('_', '/');
return JSON.parse(window.atob(base64));
};
console.log(parseJwt('jwt_token'))
@ericbrian
Copy link

You are missing the "l" in payoad.

@mattcarp12
Copy link

Can you explain why line 3 is required?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment