Permalink
Browse files

fixed docs

  • Loading branch information...
1 parent a1a4cb8 commit ce7e1917d936c3b983c85e77ccd0153d9d59f150 @disfated disfated committed Jan 24, 2012
Showing with 8 additions and 8 deletions.
  1. +8 −8 README.md
View
@@ -38,7 +38,7 @@ Basic method to make a request of any type. The function returns a RestRequest o
#### events
-* `complete: function(data, response)` - emitted when the request has finished whether it was successful or not. Gets passed the response data and the response object as arguments. If some error has occurred, `data` is always instance of `Error`.
+* `complete: function(result, response)` - emitted when the request has finished whether it was successful or not. Gets passed the response result and the response object as arguments. If some error has occurred, `result` is always instance of `Error`, otherwise it contains response data.
* `success: function(data, response)` - emitted when the request was successful. Gets passed the response data and the response object as arguments.
* `fail: function(data, response)` - emitted when the request was successful, but 4xx status code returned. Gets passed the response data and the response object as arguments.
* `error: function(err, response)` - emitted when some errors have occurred (eg. connection aborted, parse, encoding, decoding failed or some other unhandled errors). Gets passed the `Error` object and the response object (when available) as arguments.
@@ -55,7 +55,7 @@ Basic method to make a request of any type. The function returns a RestRequest o
### get(url, options)
-Create a GET request.
+Create a GET request.
### post(url, options)
@@ -89,7 +89,7 @@ In case of malformed content, parsers emit `error` event. Original data returned
#### parsers.auto
-Checks the content-type and then uses parsers.xml, parsers.json or parsers.yaml.
+Checks the content-type and then uses parsers.xml, parsers.json or parsers.yaml.
If the content type isn't recognised it just returns the data untouched.
#### parsers.json, parsers.xml, parsers.yaml
@@ -122,12 +122,12 @@ Example usage
var sys = require('util'),
rest = require('./restler');
-rest.get('http://google.com').on('complete', function(err, data) {
- if (err) {
- sys.puts('Error: ' + err.message);
+rest.get('http://google.com').on('complete', function(result) {
+ if (result instanceof Error) {
+ sys.puts('Error: ' + result.message);
this.retry(5000); // try again after 5 sec
} else {
- sys.puts(data);
+ sys.puts(result);
}
});
@@ -184,7 +184,7 @@ rest.postJson('http://example.com/action', jsonData).on('complete', function(dat
});
```
-
+
Running the tests
-----------------
install **[nodeunit](https://github.com/caolan/nodeunit)**

0 comments on commit ce7e191

Please sign in to comment.