Node.js Question:

How to extract POST data in node.js?

Tweet Share WhatsApp

Answer:

If you use Express (High performance, high class web development for Node.js), you can do this:

HTML:

<form method="post" action="/">
<input type="text" name="user[name]">
<input type="text" name="user[email]">
<input type="submit" value="Submit">
</form>

Javascript:

app.use(express.bodyParser();

app.post('/', function(request, response){

console.log(request.body.user.name);
console.log(request.body.user.email);

});

Download Node.js PDF Read All 15 Node.js Questions
Previous QuestionNext Question
Can we use jQuery with Node.js?Tell me how to make an HTTP POST request in node.js?