Skip to content

Commit

Permalink
Moving basic example to the top.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeal committed Feb 11, 2011
1 parent d1deb5b commit d67a041
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ Or from source:

Request is designed to be the simplest way possible to make http calls. It support HTTPS and follows redirects by default.

<pre>
var request = require('request');
request({uri:'http://www.google.com'}, function (error, response, body) {
if (!error && response.statusCode == 200) {
sys.puts(body) // Print the google web page.
}
})
</pre>

#### request(options, callback)

The first argument is an options object. The only required option is uri, all others are optional.
Expand All @@ -38,14 +47,6 @@ The first argument is an options object. The only required option is uri, all ot
The callback argument gets 3 arguments. The first is an error when applicable (usually from the http.Client option not the http.ClientRequest object). The second in an http.ClientResponse object. The third is the response body buffer.

Examples:
<pre>
var request = require('request');
request({uri:'http://www.google.com'}, function (error, response, body) {
if (!error && response.statusCode == 200) {
sys.puts(body) // Print the google web page.
}
})
</pre>

<pre>
var request = require('request');
Expand Down

0 comments on commit d67a041

Please sign in to comment.