Skip to content

Instantly share code, notes, and snippets.

@mrryanjohnston
Created June 24, 2011 20:17
Show Gist options
  • Save mrryanjohnston/1045587 to your computer and use it in GitHub Desktop.
Save mrryanjohnston/1045587 to your computer and use it in GitHub Desktop.
var http = require('http');
var options = {
host: 'url',
port: 80,
path: 'path',
method: 'POST'
};
var req = function(callback) {
http.request(options, function(res) {
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log("Body: " + chunk);
});
});
callback(res);
}
req(function(res) {
//Do stuff
});
req.on('error', function(e) {
console.log('problem with request: ' + e.message);
});
req.write('data\n');
req.end();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment