Cookies Psst! Do you accept cookies?

We use cookies to enhance and personalise your experience.
Please accept our cookies. Checkout our Cookie Policy for more information.

Cannot read property 'jwtoken' of undefined

Cannot read property 'jwtoken' of undefined

Oct 14 '21 Comments: 1 Answers: 0 0

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
Open Full Question

Last Stories

What's your thoughts?

Please Register or Login to your account to be able to submit your comment.