An Interest In:
Web News this Week
- April 24, 2024
- April 23, 2024
- April 22, 2024
- April 21, 2024
- April 20, 2024
- April 19, 2024
- April 18, 2024
October 14, 2021 12:42 am GMT
Original Link: https://dev.to/suvamray/cannot-read-property-jwtoken-of-undefined-jik
Cannot read property 'jwtoken' of undefined
here I generate the token at backend in express..............
router.post("/login",async(req,res)=>{ const {email,password}=req.body; if(!email || !password){ return res.status(401).send({error:"please filled the data properly"}); } try { const loginUser=await User.findOne({email:email}); if(!loginUser){ return res.status(400).send({error:"not found"}); } const isMatch = await bcrypt.compare(password,loginUser.password); if(isMatch){ const token=await loginUser.generateToken(); res.cookie("jwtoken",token,{ expires:new Date(Date.now()+15000000), httpOnly:true, //secure:true //it
Original Link: https://dev.to/suvamray/cannot-read-property-jwtoken-of-undefined-jik
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To