The easiest way to pass data to the server is by adding it to the querystring. This way we don’t have to do a lot of client-side setup to test our code, and if we take advantage of any of the popular client-side or server-side frameworks, we’ll probably send parameters using routes, which is not so terribly different.
Node provides a
querystring module, so we don’t have to
do as much parsing of the request URL to get to the querystring data. The
one thing we need to do is trim the querystring, since the
querystring module separates out the pieces, but doesn’t
separate the querystring from the rest of the URL. After adding the new
module, we can reuse the basic Hello World code we wrote, getting it to
take and process some input without needing too many changes:
var http = require("http"), querystring = require("querystring"); ...