Over a million developers have joined DZone.
Platinum Partner

GET / POST Parameter In Node.js

· Web Dev Zone

The Web Dev Zone is brought to you in partnership with Mendix.  Discover how IT departments looking for ways to keep up with demand for business apps has caused a new breed of developers to surface - the Rapid Application Developer.

GET / POST Parameter In Node.js is pretty simple.  Only 5 lines of code to insert into your project.

var sys = require ('sys'),
url = require('url'),
http = require('http'),
qs = require('querystring');

http.createServer(function (req, res) {

    if(req.method=='POST') {
            var body='';
            req.on('data', function (data) {
                body +=data;

                var POST =  qs.parse(body);
    else if(req.method=='GET') {
        var url_parts = url.parse(req.url,true);

}).listen(1337, "");

The Web Dev Zone is brought to you in partnership with Mendix.  Learn more about The Essentials of Digital Innovation and how it needs to be at the heart of every organization.

web dev,node.js

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}