Created
June 4, 2014 05:54
-
-
Save lmatt-bit/1902d501d4f7018cfd60 to your computer and use it in GitHub Desktop.
Node.js use request library to post/get
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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