![](/img/trans.png)
[英]How to get partials to show when using ui-router with expressjs?
[英]How can I get value in the “post” router using expressJS?
我在nodejs方面很新鲜,如表所示。
假设我从POST方法中获取返回值,如何从GET中获取返回值? 我认为app.use() ,我知道中间件只能处理请求,但是当时我还不知道。
...
var Some = require('./Some');
app.get('/',function(req,res){
res.render({
title:"hi",
output: data || '' <--------I wanna get data from below
})
});
app.post('/',function(req,res){
var some = new Some();
some.postOriginCode(code,function(data){
data <-------- here is the data i want.
//I can do it the way,but I don't like.
res.render('index', {output:data});
});
});
...
var Some = require('./Some');
app.get('/',function(req,res){
res.render({
title:"hi",
output:app.get('data')
})
});
app.post('/',function(req,res){
var some = new Some();
some.postOriginCode(code,function(data){
app.set('data',data);
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.