@govuk-pay/pay-js-commons 6.0.1 → 6.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +19 -3
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -166,11 +166,27 @@ Or a pence value can be converted to GBP
166
166
  </dl>
167
167
  ```
168
168
 
169
- ### Https base client
169
+ ## Axios base client
170
170
 
171
- Used in our Node.js apps to call internal APIs such as connector or ledger.
171
+ Used in our Node.js apps to call APIs such as connector or ledger.
172
172
 
173
- Uses the NPM Axios library.
173
+ Uses the NPM [Axios](https://www.npmjs.com/package/axios) library.
174
+
175
+ The base client provides the following configuration options:
176
+ * onRequestStart - Callback function before starting a API request. Mainly used for logging.
177
+ * onSuccessResponse - Callback function when request has completed successfully.
178
+ * onFailureResponse - Callback function when request has failed.
179
+ * acceptAllStatusCodes - `boolean`
180
+ * By default all non 2xx responses are considered failed requests.
181
+ * Set this to `true` and all status codes are considered a successful request. You code will then need to handle the response appropriately. Currently, only `pay-frontend` requires this to be set to `true`.
182
+
183
+ ### Built in in retry functionality
184
+
185
+ If a `GET` request provides a response with the error message `ECONNRESET` - the the Axios base client will automatically try that request another 2 times - 3 times in total.
186
+
187
+ By default, on each failed request, it will call the `onFailureResponse` callback.
188
+
189
+ If `acceptAllStatusCodes=true`, then it will call the `onSuccessResponse` callback.
174
190
 
175
191
  ## Releasing
176
192
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@govuk-pay/pay-js-commons",
3
- "version": "6.0.1",
3
+ "version": "6.0.3",
4
4
  "description": "Reusable js scripts for GOV.UK Pay Node.js projects",
5
5
  "engines": {
6
6
  "node": "^18.17.1"