Service for reading a site's storefront product category tree.
Accessible via lynkow.productCategories. Only categories the merchant made
visible appear, with nesting represented by each node's children. Requires a
publishable key: pass publishableKey to createClient(...) so every request
carries it (commerce routes reject calls without a valid key). Responses are
cached in-memory for 5 minutes (SHORT TTL) when a cache adapter is configured on
the client.
Access via: lynkow.productCategories
Methods
1 method
tree
tree(options?: BaseRequestOptions): Promise<ProductCategoryTreeNode[]>Retrieves the merchant-visible category tree, ordered at every level.
Nesting is represented recursively through children; leaves have an empty
array. Cached for 5 minutes.
Parameter | Type | Description |
|---|---|---|
|
| Base request options (locale override, custom fetch options). |
Returns: Promise<ProductCategoryTreeNode[]>
const roots = await lynkow.productCategories.tree()
for (const root of roots) {
console.log(root.name, root.children.map((child) => child.name))
}