...
newArticle.save((err,newArticle)=>{
if(err){
req.flash('error','Sorry , an error has occured. Thamk you try again later')
//when i use console.log(req.flash('error')) it shows normally in the terminal
return res.redirect('/AddArticle')
}else{
req.flash('success','Thank you , your article has been added')
//when i use console.log(req.flash('success')) it shows normally in the terminal
return res.redirect('/AddArticle')
}
})
}
this is the route fonction:
router.post('/AddFormArticle',control.FormAddArticle)
this is control FormAddArticle function that i used to render the flash message and the page:
exports.FormAddArticle = (req,res)=>{
res.render('FormArticle',{title : "Ajouter un Article" , success : req.flash('success') ,
error : req.flash('error') })