Skip to content

Instantly share code, notes, and snippets.

@victorkurauchi
Created July 15, 2014 21:05
Show Gist options
  • Select an option

  • Save victorkurauchi/6bc1e84aa11867f71c85 to your computer and use it in GitHub Desktop.

Select an option

Save victorkurauchi/6bc1e84aa11867f71c85 to your computer and use it in GitHub Desktop.
var querystring = require('querystring')
, http = require('http');
var data = querystring.stringify({
username: 'yourUsernameValue',
});
var options = {
host: 'http://localhost',
port: 3000,
path: '/api/product',
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.byteLength(data)
}
};
var req = http.request(options, function(res) {
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log("body: " + chunk);
});
});
console.log(req);
req.write(data);
req.end();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment