Skip to content

Instantly share code, notes, and snippets.

@lmatt-bit
Created June 4, 2014 05:54
Show Gist options
  • Select an option

  • Save lmatt-bit/1902d501d4f7018cfd60 to your computer and use it in GitHub Desktop.

Select an option

Save lmatt-bit/1902d501d4f7018cfd60 to your computer and use it in GitHub Desktop.
Node.js use request library to post/get
var request = require('request');
request.post(
'http://url/',
{form:
{
"query" : "test",
"position" : "top"
}
},
function(error, resp, body) {
if(!error && resp.statusCode == 200) {
console.log(body);
} else {
console.log(resp);
}
}
);
request('http://www.google.com', function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log(body) // Print the google web page.
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment