commerce-sdk-isomorphic 3.1.0 → 3.2.0

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.
package/README.md CHANGED
@@ -84,10 +84,35 @@ const config = {
84
84
 
85
85
  For more info, refer to the [documentation site](https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/).
86
86
 
87
+ #### `throwOnBadResponse`
88
+
89
+ When `true`, the SDK throws an `Error` on responses whose status is not 2xx or 304. By default, the value of this flag is `false` for backwards compatibility. Below is an example for accessing the error object via `e.response.json()`.
90
+
91
+ ```js
92
+ const config = {
93
+ throwOnBadResponse: true
94
+ // rest of the config object...
95
+ };
96
+
97
+ const shopperSearch = new ShopperSearch({
98
+ ...config
99
+ });
100
+
101
+ // in an async function
102
+ try {
103
+ const searchResult = await shopperSearch.productSearch({
104
+ parameters: { q: "shirt" },
105
+ });
106
+ } catch (e) {
107
+ const error = await e.response.json();
108
+ console.log(error);
109
+ // error is the JSON object - {error: ",,,"}
110
+ }
111
+ ```
112
+
87
113
  #### Additional Config Settings
88
114
 
89
115
  * `headers`: Headers to include with API requests.
90
- * `throwOnBadResponse`: When `true`, the SDK throws an `Error` on responses whose status is not 2xx or 304.
91
116
 
92
117
  ### Custom Query Parameters
93
118