You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+12-12Lines changed: 12 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,12 @@
12
12
13
13
When the connection fails with one of `ECONNRESET`, `ENOTFOUND`, `ESOCKETTIMEDOUT`, `ETIMEDOUT`, `ECONNREFUSED`, `EHOSTUNREACH`, `EPIPE`, `EAI_AGAIN` or when an HTTP 5xx error occurrs, the request will automatically be re-attempted as these are often recoverable errors and will go away on retry.
14
14
15
+
## Installation
16
+
17
+
Install with [npm](https://npmjs.org/package/requestretry).
18
+
19
+
npm install --save requestretry
20
+
15
21
## Usage
16
22
17
23
Request-retry is a drop-in replacement for [request](https://github.com/mikeal/request) but adds two new options `maxAttempts` and `retryDelay`. It also adds one property to the response, `attempts`. It supports callbacks or promises.
@@ -22,8 +28,8 @@ Request-retry is a drop-in replacement for [request](https://github.com/mikeal/r
22
28
var request =require('requestretry');
23
29
24
30
request({
25
-
url:'https://api.domain.com/v1/a/b'
26
-
json:true,
31
+
url:'https://api.domain.com/v1/a/b',
32
+
json:true,
27
33
28
34
// The below parameters are specific to request-retry
29
35
maxAttempts:5, // (default) try 5 times
@@ -45,8 +51,8 @@ When you're using promises, you can pass the two following options:
45
51
46
52
```javascript
47
53
request({
48
-
url:'https://api.domain.com/v1/a/b'
49
-
json:true,
54
+
url:'https://api.domain.com/v1/a/b',
55
+
json:true,
50
56
51
57
fullResponse:true// (default) To resolve the promise with the full response or just the body
52
58
})
@@ -78,8 +84,8 @@ function customPromiseFactory(resolver) {
78
84
}
79
85
80
86
request({
81
-
url:'https://api.domain.com/v1/a/b'
82
-
json:true,
87
+
url:'https://api.domain.com/v1/a/b',
88
+
json:true,
83
89
84
90
// Custom promise factory function
85
91
promiseFactory: customPromiseFactory
@@ -92,12 +98,6 @@ request({
92
98
})
93
99
```
94
100
95
-
## Installation
96
-
97
-
Install with [npm](https://npmjs.org/package/requestretry).
98
-
99
-
npm install --save requestretry
100
-
101
101
## How to define your own retry strategy
102
102
103
103
A retry strategy let you specify when request-retry should retry a request
0 commit comments