Q:

How to decode a token with jwt

When I try to verify the token of user, I always get the Error 500. 
function verifyToken(req, res, next) {
if(!req.headers.authorization){
    return res.status(401).send('Unauthorized request')
}
let token = req.headers.authorization.split(' ')[1]
if (token === 'null') {
    return res.status(401).send('Unauthorized request')
}
let payload = jwt.verify(token, 'secretkey')
if (! payload) {
    return res.status(401).send('Unauthorized request')
}
req.userId = payload.subject
next()

I started by surround with a try catch the payload, I think I understand that jwt operation had changed and that it now needs this to work, but I don't understand why it doesn't work.  It seems he can't check the match. 
function verifyToken(req, res, next) {
if(!req.headers.authorization){
    return res.status(401).send('Unauthorized request')
}
let token = req.headers.authorization.split(' ')[1]
if (token === 'null') {
    return res.status(401).send('Unauthorized request')
}
try {
    let payload = jwt.verify(token, 'secretkey')
    req.userId = payload.subject
    next()
} catch (error) {
    return res.status(401).send('Unauthorized request')
}  

}

A:

You could use jwt-decode /npm jwt-decode library to decode.  Example from doc:
import jwt_decode from 'jwt-decode';

var token = 'eyJ0eXAiO.../// jwt token';
var decoded = jwt_decode(token);
console.log(decoded);

other library to check angular2-jwt

