Express GET and POST variable

GET params

app.get('/:name', function(req, res, next){
   var name =;
   var getvar = req.query.getvar1;

TIPS: iterate over req.query to get all GET variables

POST params

function errorHandler(err, req, res, next){
   res.render('error_template', {error: err});
app.use(errorHandler);'/', function(req, res, next){
    var favourite = req.body.fruit;
    if(typeof favourite == 'undefined'){
         next(Error('Please choose a fruit!'));
    } else {
         // success 

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s