JWT with mysql with middle ware

PHOTO EMBED

Tue Nov 28 2023 04:20:24 GMT+0000 (Coordinated Universal Time)

Saved by @sid_balar

var jwt = require('jsonwebtoken');

function auth(req, res, next) {
    try {
        // Assuming the token is sent in the Authorization header as "Bearer <token>"
        const token = req.headers.authorization.split(' ')[1];
        jwt.verify(token, 'hello', function(err, decoded) {
            if (err) {
                return res.status(401).json({
                    status: "error",
                    message: "Unauthorized"
                });
            }
            req.userData = decoded;
            next();
        });
    } catch (error) {
        return res.status(500).json({
            status: "error",
            message: "Internal Server Error"
        });
    }
}

module.exports = auth;
content_copyCOPY

Which place to passs token in postman? ==> Authorization > Bearer Token > put token