Apply suggestions from code review

Co-authored-by: Luis Alvarez D. <luis@vercel.com>
This commit is contained in:
Dom Sip 2022-04-19 10:23:25 +01:00 committed by GitHub
parent 471813ad83
commit 8909e94a6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 11 deletions

View File

@ -21,7 +21,7 @@
}
```
## Refrences:
## References
- SDK: https://github.com/SalesforceCommerceCloud/commerce-sdk
- isomorphic SDK (currently not used atm): https://github.com/SalesforceCommerceCloud/commerce-sdk-isomorphic
- PWA Kit storefront example: https://pwa-kit.mobify-storefront.com/

View File

@ -10,16 +10,8 @@ const getProducts: ProductsEndpoint['handlers']['getProducts'] = async ({
}) => {
const { sdk } = config;
let searchTerm = search;
if (categoryId) {
searchTerm = categoryId as string
}
// set default for main category
if (!searchTerm) {
searchTerm = 'clothing'
}
// 'clothing' is our main category default, and a manually set category has priority
const searchTerm = categoryId ? categoryId as string : search || 'clothing';
const searchClient = await sdk.getSearchClient();
// use SDK search API for initial products