-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
15 additions
and
18 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,31 @@ | ||
# Request -- Simplified HTTP request method | ||
|
||
### Install | ||
## Install | ||
|
||
<pre> | ||
npm install request | ||
</pre> | ||
|
||
### Super simple to use | ||
## Super simple to use | ||
|
||
request(options, callback); | ||
#### request(options, callback) | ||
|
||
The first argument is an options object. The only required option is uri, all others are optional. | ||
|
||
* `'uri'` - fully qualified uri or a parsed url object from url.parse() | ||
* `'method'` - http method, defaults to GET | ||
* `'headers'` - http headers, defaults to {} | ||
* `'body'` - entity body for POST and PUT requests | ||
* `'client'` - existing http client object (when undefined a new one will be created and assigned to this property so you can keep around a reference to it if you would like use keep-alive on later request) | ||
|
||
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. | ||
|
||
Example: | ||
<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> | ||
|
||
### Options | ||
|
||
The first argument is an options object. The only required option is uri, all others are optional. | ||
|
||
uri : fully qualified uri or a parsed url object from url.parse() | ||
method : http method, defaults to GET | ||
headers : http headers, defaults to {} | ||
body : entity body for POST and PUT requests | ||
client : existing http client object (when undefined a new one will be created and assigned to this property so you can keep around a reference to it if you would like use keep-alive on later request) | ||
|
||
### callback | ||
|
||
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. | ||
</pre> |