[英]How can I get value in the “post” router using expressJS?
i am fresh in nodejs,so as express. 我在nodejs方面很新鲜,如表所示。
Assuming I'm get the return value from in POST method, how can i get it from GET? 假设我从POST方法中获取返回值,如何从GET中获取返回值? I think, app.use() , I know the middleware can only handler the requests,but at the time, i have not idea.
我认为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.