response.redirect('URL');
used to redirect a request to another page
the code
router.post('/sign_in',urlend,function(req,res){
var email=req.body.user_id;
var password=req.body.password;
if(email!='' && password!=''){
user_modell.findOne({email:email,password:password},function(err,data){
if(err){
console.log('error');
} else if(!data){
console.log('Incorrect User ID or Password');
return res.end();
}else{
res.redirect("/confirm");
}
});
}
res.end();
});
You can use express-redirect package.
An explanation for your mistake
[ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
, . model.findOne
- -. , . , res.end()
. .
, : - /, : " , ", /. , , , , , , !