From 19ee8de4563883ad6183fdf4b99f4cf016a37665 Mon Sep 17 00:00:00 2001 From: Oliver Heywood Date: Mon, 11 Oct 2021 10:42:55 -0500 Subject: [PATCH] turns out the if statements here are necesary --- framework/ordercloud/product/use-search.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/framework/ordercloud/product/use-search.tsx b/framework/ordercloud/product/use-search.tsx index a8bed6581..4b39fefb4 100644 --- a/framework/ordercloud/product/use-search.tsx +++ b/framework/ordercloud/product/use-search.tsx @@ -12,10 +12,11 @@ export const handler: SWRHook = { // Use a dummy base as we only care about the relative path const url = new URL(options.url!, 'http://a') - url.searchParams.set('search', String(search)) - url.searchParams.set('categoryId', String(categoryId)) - url.searchParams.set('brandId', String(brandId)) - url.searchParams.set('sort', String(sort)) + + if (search) url.searchParams.set('search', String(search)) + if (categoryId) url.searchParams.set('categoryId', String(categoryId)) + if (brandId) url.searchParams.set('brandId', String(brandId)) + if (sort) url.searchParams.set('sort', String(sort)) return fetch({ url: url.pathname + url.search,