Skip to content

Commit 5052add

Browse files
committed
Improve README.
1 parent 9a50640 commit 5052add

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212

1313
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.
1414

15+
## Installation
16+
17+
Install with [npm](https://npmjs.org/package/requestretry).
18+
19+
npm install --save requestretry
20+
1521
## Usage
1622

1723
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
2228
var request = require('requestretry');
2329

2430
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,
2733

2834
// The below parameters are specific to request-retry
2935
maxAttempts: 5, // (default) try 5 times
@@ -45,8 +51,8 @@ When you're using promises, you can pass the two following options:
4551

4652
```javascript
4753
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,
5056

5157
fullResponse: true // (default) To resolve the promise with the full response or just the body
5258
})
@@ -78,8 +84,8 @@ function customPromiseFactory(resolver) {
7884
}
7985

8086
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,
8389

8490
// Custom promise factory function
8591
promiseFactory: customPromiseFactory
@@ -92,12 +98,6 @@ request({
9298
})
9399
```
94100

95-
## Installation
96-
97-
Install with [npm](https://npmjs.org/package/requestretry).
98-
99-
npm install --save requestretry
100-
101101
## How to define your own retry strategy
102102

103103
A retry strategy let you specify when request-retry should retry a request

0 commit comments

Comments
 (0)