jeudi 18 février 2021

using redirect and passing user info in express

I am new to express. I want to redirect req.body containing user name and password to home and use the login information afterwards.

Please tell me the fix and is this how it is done?

server.post('/login',(req,res)=>{
   idpassmodel.find({name:req.body.id,password:req.body.pass}).exec((err,display)=>{
  if(err){
    res.redirect('/');
  }
  else{
    console.log(display);
      if(display.length==0)    res.redirect('/');
       else
        res.redirect('/home');// here i want to add res.redirect('/home',req.body)
     }
   });
})



Aucun commentaire:

Enregistrer un commentaire