@@ -8,16 +8,14 @@ nestjs module that just doing little modification to the original and good **nes
8
8
9
9
## features
10
10
* axios - the most used package for http requests in npm and the one used by nestjs official http library.
11
- * better axios stack trace - axios has an [ open issue] ( https://github.com/axios/axios/issues/2387 ) about improvement of their stack trace.
12
- in this library there is a default interceptor that will intercept the stack trace and will add data to it.
13
- * promise based - most of us using the current http module that uses observable which we don't use most of the time
11
+ * promise based - most of us using the current http module that uses observable which we don't use most of the time
14
12
and in order to avoid it were just calling ` .toPromise() ` every http call.
15
13
* retries - in many cases we will want to retry a failing http call.
16
14
with observable we could just add the retry operator (rxjs) but with promises we need to implement this logic ourselves.
17
15
this package will make it easy for you, just pass ` { retries: NUMBER_OF_RETRIES } ` in the config of the http module.
18
16
** more details in the configuration section**
19
-
20
- ## quick start
17
+
18
+ ## quick start
21
19
### installing
22
20
Using npm:
23
21
```
@@ -34,7 +32,7 @@ $ yarn add nestjs-http-promise
34
32
``` ts
35
33
import { HttpModule } from ' nestjs-http-promise'
36
34
37
- @Module ({
35
+ @Module ({
38
36
imports: [HttpModule ]
39
37
})
40
38
```
@@ -51,7 +49,7 @@ class Demo {
51
49
use the service:
52
50
``` ts
53
51
public callSomeServer (): Promise < object > {
54
- return this.httpService.get(' http://fakeService' )
52
+ return this.httpService.get(' http://fakeService' )
55
53
}
56
54
` ` `
57
55
@@ -68,7 +66,7 @@ import { HttpModule } from 'nestjs-http-promise'
68
66
imports: [HttpModule .register (
69
67
{
70
68
timeout: 1000 ,
71
- retries: 5 ,
69
+ retries: 10 ,
72
70
...
73
71
}
74
72
)]
@@ -77,7 +75,6 @@ import { HttpModule } from 'nestjs-http-promise'
77
75
78
76
### default configuration
79
77
* default config of axios-retry : https://github.com/softonic/axios-retry#options
80
- * better axios stack trace is added by default, you can turn it off by passing the ** isBetterStackTraceEnabled** to false.
81
78
82
79
## async configuration
83
80
When you need to pass module options asynchronously instead of statically, use the ` registerAsync() ` method ** just like in nest httpModule** .
@@ -88,14 +85,14 @@ you have a couple of techniques to do it:
88
85
HttpModule .registerAsync ({
89
86
useFactory : () => ({
90
87
timeout: 1000 ,
91
- retries: 5 ,
88
+ retries: 10 ,
92
89
...
93
90
}),
94
91
});
95
92
```
96
93
97
94
* using class
98
-
95
+
99
96
``` ts
100
97
HttpModule .registerAsync ({
101
98
useClass: HttpConfigService ,
@@ -109,13 +106,13 @@ class HttpConfigService implements HttpModuleOptionsFactory {
109
106
const configurationData = await someAsyncMethod ();
110
107
return {
111
108
timeout: configurationData .timeout ,
112
- retries: 5 ,
109
+ retries: 10 ,
113
110
...
114
111
};
115
112
}
116
113
}
117
114
```
118
- If you want to reuse an existing options provider instead of creating a copy inside the HttpModule,
115
+ If you want to reuse an existing options provider instead of creating a copy inside the HttpModule,
119
116
use the useExisting syntax.
120
117
``` ts
121
118
HttpModule .registerAsync ({
0 commit comments