I am implementing a token based authentication and I need to access the token I have set when i check if the user is authenticated.
I am using this method to check if the user is authenticated:
function isAuthenticated(req, res, next) {
    const token = req.headers['authorization'];
    console.log(token);
    if (token) {
        req.token = token;
        next();
    } else {
        res.sendStatus(401);
    }
}
The console.log(token) prints out [object Object] how can I convert this to a json object?
The token is generated with the jsonwebtoken module this way:
jwt.sign({ user_id: user.user_id }, config.app.secretKey, { expiresIn: 60 * 60 * 24 * 7 }, (err, token) => {
    return res.send(token);
});
