Showing posts with label expressjs. Show all posts
Showing posts with label expressjs. Show all posts

Saturday, May 21, 2011

req.body undefined in POST request in Express js

You have to use a bodyparser to process the body of a POST request

app.use(express.bodyParser());

and put this before the routing definition, like this

app.configure('development', function() {

console.log("Development mode");

app.configure(function() {
app.use(express.bodyParser());
app.use(app.router);
.....
});
});


here is the related google groups thread.

Thursday, January 20, 2011

EJS default escaping

In EJS (Embedded JavaScript) escaping is a default behaviour.

// escape by default
<%= VARIABLE_NAME %>

This can easily mess up a couple of things (including JSON, HTML rendering), luckily you can turn it off by using

// render out string
<%- VARIABLE_NAME %>