Friday, 6 September 2013

How can I get value in the “post” router using expressJS?

How can I get value in the "post" router using expressJS?

i am fresh in nodejs,so as express.
Assuming I'm get the return value from in POST method, how can i get it
from GET? I think,app.use() , I know the middleware can only handler the
requests,but at the time, i have not idea.
...
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});
});
});
...

No comments:

Post a Comment