[node.js] node.js : parsing GET/POST query Data
var http = require('http');
var url = require('url');
var qs = require('querystring'); // for postQuery data
var app = http.createServer(function(req, res){
var _url = url.parse(req.url, true);
// GET Query data object
var getQuery = _url.query;
// POST Query data object
var postQuery = null;
var body = "";
req.on('data', function(data){
body += data;
})
req.on('end', function(){
postQuery = qs.parse(body);
console.log("postQuery: ", postQuery);
});
...
// ex)
var id = getQuery.id;
var title = postQuery.title;
...
});