在我的代码中,当我从添加数据重定向时,在这种情况下,它不会获取最新的数据,但当我刷新时,它会获取该数据
var CountryResponseData = [];
router.get('/', ensureAuthenticated, (req, res) => {
Country.find({}).then(countrylist =>{
console.log(countrylist);
if(countrylist){
CountryResponseData = countrylist;
}else{
CountryResponseData = "empty";
}
});
res.render('countrymgmt/list', { layout: "layoutinternal", title: "List Of Countries","countries":CountryResponseData });
});
这将是一个问题,因为从数据库中提取数据直到它呈现视图页面需要花费时间
var CountryResponseData = [];router.get('/', ensureAuthenticated, (req, res) => {
Country.find({}).then(countrylist =>{
console.log(countrylist);
if(countrylist){
res.render('countrymgmt/list', { layout: "layoutinternal", title: "List Of Countries","countries":countrylist });
}else{
res.render('countrymgmt/list', { layout: "layoutinternal", title: "List Of Countries","countries":[] });
}
});
});