diff --git a/components/cart/CartSidebarView/CartSidebarView.tsx b/components/cart/CartSidebarView/CartSidebarView.tsx
index 5fa3c04d5..e2cfab68c 100644
--- a/components/cart/CartSidebarView/CartSidebarView.tsx
+++ b/components/cart/CartSidebarView/CartSidebarView.tsx
@@ -42,7 +42,7 @@ const CartSidebarView: FC = () => {
{isEmpty ? (
-
+
) : (
diff --git a/components/core/UserNav/UserNav.tsx b/components/core/UserNav/UserNav.tsx
index 0a2241fbd..8e4949ba1 100644
--- a/components/core/UserNav/UserNav.tsx
+++ b/components/core/UserNav/UserNav.tsx
@@ -25,9 +25,11 @@ const UserNav: FC
= ({ className }) => {
- openSidebar()}>
-
- {itemsCount}
-
+ {itemsCount > 0 && (
+
+ {itemsCount}
+
+ )}
-
diff --git a/lib/bigcommerce/api/cart.ts b/lib/bigcommerce/api/cart.ts
index 1a563b943..3f917cabc 100644
--- a/lib/bigcommerce/api/cart.ts
+++ b/lib/bigcommerce/api/cart.ts
@@ -142,11 +142,9 @@ const cartApi: BigcommerceApiHandler = async (req, res, config) => {
})
}
- const { data } = await config.storeApiFetch(
+ const result = await config.storeApiFetch<{ data: any } | null>(
`/v3/carts/${cartId}/items/${itemId}`,
- {
- method: 'DELETE',
- }
+ { method: 'DELETE' }
)
// Update the cart cookie
@@ -155,7 +153,7 @@ const cartApi: BigcommerceApiHandler = async (req, res, config) => {
getCartCookie(config.cartCookie, cartId, config.cartCookieMaxAge)
)
- return res.status(200).json({ data })
+ return res.status(200).json({ data: result?.data })
}
} catch (error) {
console.error(error)
diff --git a/lib/bigcommerce/api/utils/fetch-store-api.ts b/lib/bigcommerce/api/utils/fetch-store-api.ts
index 687c53c0e..0f0daedfe 100644
--- a/lib/bigcommerce/api/utils/fetch-store-api.ts
+++ b/lib/bigcommerce/api/utils/fetch-store-api.ts
@@ -37,9 +37,8 @@ export default async function fetchStoreApi(
)
}
- const data = await res.json()
-
- return data
+ // If something was removed, the response will be empty
+ return res.status === 204 ? null : await res.json()
}
async function getErrorText(res: Response) {