我需要在getAllarticle頁(yè)面中查詢數(shù)據(jù)庫(kù)并且取出json數(shù)據(jù),但這個(gè)數(shù)據(jù)要傳到另一個(gè)頁(yè)面渲染,這時(shí)候該怎么做呢?res.redirect我試了一下沒(méi)成功,不知道是不是我姿勢(shì)不對(duì)?//getAllarticle取數(shù)據(jù)
exports.getAllarticle?=?function?(req,res,next)?{
????var?page?=?parseInt(req.query.page);
????db.find("article",{},{"pageamount":10,"page":page,"sort":{"datetime":-1}},function(err,result){
????????res.json(result);
????});
};
//需要接收數(shù)據(jù)的showArticle?
exports.showArticle?=?function?(req,res,next)?{
????????res.render('article/article',?{
????????????"login":?req.session.login?==?"1"???true?:?false,
????????????"username":?req.session.login?==?"1"???req.session.username?:?"",
????????})
????????;
};
一個(gè)頁(yè)面取到的json數(shù)據(jù)要怎么傳到另一個(gè)頁(yè)面
村中長(zhǎng)相較好的男子
2018-01-07 01:33:56