UNPKG

1.92 kBMarkdownView Raw
1
2# superagent-retry
3
4 Extends the node version of [`visionmedia/superagent`][superagent]'s `Request`, adds a `.retry` method to add retrying logic to the request. Calling this will retry the request however many additional times you'd like.
5
6
7 [superagent]: https://github.com/visionmedia/superagent
8
9## Usage
10
11```javascript
12var superagent = require('superagent');
13require('superagent-retry')(superagent');
14
15superagent
16 .get('https://segment.io')
17 .retry(2) // retry twice before responding
18 .end(onresponse);
19
20
21function onresponse (res) {
22 console.log(res.status, res.headers);
23 console.log(res.body);
24}
25```
26
27## Retrying Cases
28
29 Currently the retrying logic checks for:
30
31 * ECONNRESET
32 * ETIMEDOUT
33 * EADDRINFO
34 * ESOCKETTIMEDOUT
35 * superagent client timeouts
36 * bad gateway errors (503s)
37
38
39## License
40
41(The MIT License)
42
43Copyright (c) 2013 Segmentio <friends@segment.io>
44
45Permission is hereby granted, free of charge, to any person obtaining
46a copy of this software and associated documentation files (the
47'Software'), to deal in the Software without restriction, including
48without limitation the rights to use, copy, modify, merge, publish,
49distribute, sublicense, and/or sell copies of the Software, and to
50permit persons to whom the Software is furnished to do so, subject to
51the following conditions:
52
53The above copyright notice and this permission notice shall be
54included in all copies or substantial portions of the Software.
55
56THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
57EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
58MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
59IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
60CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
61TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
62SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\No newline at end of file