File tree 2 files changed +38
-2
lines changed
2 files changed +38
-2
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,22 @@ Type: [object][4]
69
69
}
70
70
```
71
71
72
+ ``` js
73
+ {
74
+ helpers: {
75
+ REST : {
76
+ endpoint: ' http://site.com/api' ,
77
+ prettyPrintJson: true ,
78
+ httpAgent: {
79
+ ca: fs .readFileSync (__dirname + ' /path/to/ca.pem' ),
80
+ rejectUnauthorized: false ,
81
+ keepAlive: true
82
+ }
83
+ }
84
+ }
85
+ }
86
+ ```
87
+
72
88
## Access From Helpers
73
89
74
90
Send REST requests by accessing ` _executeRequest ` method:
Original file line number Diff line number Diff line change @@ -63,6 +63,22 @@ const config = {}
63
63
* }
64
64
* ```
65
65
*
66
+ * ```js
67
+ * {
68
+ * helpers: {
69
+ * REST: {
70
+ * endpoint: 'http://site.com/api',
71
+ * prettyPrintJson: true,
72
+ * httpAgent: {
73
+ * ca: fs.readFileSync(__dirname + '/path/to/ca.pem'),
74
+ * rejectUnauthorized: false,
75
+ * keepAlive: true
76
+ * }
77
+ * }
78
+ * }
79
+ * }
80
+ * ```
81
+ *
66
82
* ## Access From Helpers
67
83
*
68
84
* Send REST requests by accessing `_executeRequest` method:
@@ -101,9 +117,13 @@ class REST extends Helper {
101
117
102
118
// Create an agent with SSL certificate
103
119
if ( this . options . httpAgent ) {
104
- if ( ! this . options . httpAgent . key || ! this . options . httpAgent . cert )
120
+ // if one of those keys is there, all good to go
121
+ if ( this . options . httpAgent . ca || this . options . httpAgent . key || this . options . httpAgent . cert ) {
122
+ this . httpsAgent = new Agent ( this . options . httpAgent )
123
+ } else {
124
+ // otherwise, throws an error of httpAgent config
105
125
throw Error ( 'Please recheck your httpAgent config!' )
106
- this . httpsAgent = new Agent ( this . options . httpAgent )
126
+ }
107
127
}
108
128
109
129
this . axios = this . httpsAgent ? axios . create ( { httpsAgent : this . httpsAgent } ) : axios . create ( )
You can’t perform that action at this time.
0 commit comments