Cannot read property ‘jwtoken’ of undefined

Cannot read property ‘jwtoken’ of undefined

Oct 14 ’21
Comments: 1
Answers: 0


This content originally appeared on DEV Community and was authored by SuvamRay

Cannot read property 'jwtoken' of undefined

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


This content originally appeared on DEV Community and was authored by SuvamRay


Print Share Comment Cite Upload Translate Updates
APA

SuvamRay | Sciencx (2021-10-14T00:42:00+00:00) Cannot read property ‘jwtoken’ of undefined. Retrieved from https://www.scien.cx/2021/10/14/cannot-read-property-jwtoken-of-undefined/

MLA
" » Cannot read property ‘jwtoken’ of undefined." SuvamRay | Sciencx - Thursday October 14, 2021, https://www.scien.cx/2021/10/14/cannot-read-property-jwtoken-of-undefined/
HARVARD
SuvamRay | Sciencx Thursday October 14, 2021 » Cannot read property ‘jwtoken’ of undefined., viewed ,<https://www.scien.cx/2021/10/14/cannot-read-property-jwtoken-of-undefined/>
VANCOUVER
SuvamRay | Sciencx - » Cannot read property ‘jwtoken’ of undefined. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/10/14/cannot-read-property-jwtoken-of-undefined/
CHICAGO
" » Cannot read property ‘jwtoken’ of undefined." SuvamRay | Sciencx - Accessed . https://www.scien.cx/2021/10/14/cannot-read-property-jwtoken-of-undefined/
IEEE
" » Cannot read property ‘jwtoken’ of undefined." SuvamRay | Sciencx [Online]. Available: https://www.scien.cx/2021/10/14/cannot-read-property-jwtoken-of-undefined/. [Accessed: ]
rf:citation
» Cannot read property ‘jwtoken’ of undefined | SuvamRay | Sciencx | https://www.scien.cx/2021/10/14/cannot-read-property-jwtoken-of-undefined/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.