Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/core/src/base/staticClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ async function runFetch(
fetchOptions.headers["Content-Type"] = CONTENT_TYPE;
}

// To disable response caching, set cacheManager to null
if (options.client.clientConfig.cacheManager) {
fetchOptions.cacheManager = options.client.clientConfig.cacheManager;
}
Expand Down
33 changes: 29 additions & 4 deletions packages/generator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,16 @@ To use an SDK client, instantiate an object of that client and configure these p
* APIs.
*/
// Import the SDK in TypeScript or newer versions of Node.js
import CommerceSdk from "commerce-sdk";
// Import the SDK in TypeScript
import * as CommerceSdk from "commerce-sdk";
// For Javascript, use:
// import as CommerceSdk from "commerce-sdk";
const { ClientConfig, helpers, Search } = CommerceSdk;

// Older Node.js versions can instead use:
// const { ClientConfig, helpers, Search } = require("commerce-sdk");

// Create a configuration to use when creating API clients
// In TypeScript, this can be specified as const config:ClientConfig
// In TypeScript, let config = new ClientConfig();
const config = {
headers: {
connection: "close"
Expand Down Expand Up @@ -93,6 +94,30 @@ helpers.getShopperToken(config, { type: "guest" }).then(async (token) => {
});
```

## Caching

In-memory caching of responses is enabled by default. This implementation respects [standard cache headers](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control). To disable caching for a client, set cacheManager to 'null'.



### Sample Code
```javascript
const config = {
cacheManager: null,
headers: {
connection: "close"
},
parameters: {
clientId: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
organizationId: "f_ecom_bblx_stg",
shortCode: "0dnz6oep",
siteId: "RefArch"
}
}
```



When using an IDE such as VSCode, the autocomplete feature lets you view the available method and class definitions, including parameters.

Expand Down