function verifyToken(req, res, next) {
    const bearerHeader = req.headers['authorization'];

    if (typeof bearerHeader !== 'undefined') {
        const bearerToken = bearerHeader.split(" ")[1];
        req.token = bearerToken;
        next();
    } else {
        next('Token is not defined');
    }
}
/** Middleware que verifica que el header traiga un token JWT */
Middleware que verifica que el header traiga un token JWT
Middleware que verifica que el header traiga un token JWT
function verifyToken(req, res, next) {
    const bearerHeader = req.headers['authorization'];
    if (typeof bearerHeader !== 'undefined') {
        const bearerToken = bearerHeader.split(" ")[1];
        req.token = bearerToken;
        next();
    } else {
        next('Token is not defined');
    }
}
function verifyToken ( req , res , next ) { const bearerHeader = req . headers [ 'authorization' ] ; if ( typeof bearerHeader !== 'undefined' ) { const bearerToken = bearerHeader . split ( " " ) [ 1 ] ; req . token = bearerToken ; next ( ) ; } else { next ( 'Token is not defined' ) ; } }
Middleware que verifica que el header traiga un token JWT
Middleware que verifica que el header traiga un token JWT