skip to Main Content

Javascript – verifyToken in node js

verify Toekn error in node js i send token to post man but error found show in postman verify token are not verify in postman send error 401 const jwtEmail=req.body.email.split("@")[0] console.log(jwtEmail) const token=jwt.sign({user_data:email},jwtEmail,{ expiresIn:"24h" } ) const verifyToken=async(req,res,next)=>{ try {…

VIEW QUESTION

Javascript – Cannot read properties of undefined (reading 'split'), how to remove error in jwt token verify

const jwtEmail=req.body.email.split("@")[0] console.log(jwtEmail) const token=jwt.sign({user_data:email},jwtEmail,{ expiresIn:"24h" } ) const verifyToken=async(req,res,next)=>{ try { const token = req.header.authorization.split("")[0]; const user_data =await User.findOne({auth_token:token}) const jwtEmail = user_data.email.split("@")[0]; const decodedToken = jwt.verify(token,jwtEmail); next(); } catch (error) { return res.status(401).send({ message: "Auth failed", error });…

VIEW QUESTION
Back To Top
Search