import jwt from "jsonwebtoken";
const secret = "test";
const auth = async (req, res, next) => {
try {
const token = req.headers.authorization.split(" ")[1];
const isCustomAuth = token.length < 500;
let decodedData;
if (token && isCustomAuth) {
decodedData = jwt.verify(token, secret);
req.userId = decodedData?.id;
}
console.log("decodedData: " + decodedData);
next();
} catch (error) {
console.log(error);
}
};
export default auth;
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (1)
and decodedData is showing Object Object