mirror of
https://github.com/vercel/commerce.git
synced 2025-07-22 20:26:49 +00:00
Fix cart removal
This commit is contained in:
@@ -142,11 +142,9 @@ const cartApi: BigcommerceApiHandler<Cart> = 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<Cart> = 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)
|
||||
|
@@ -37,9 +37,8 @@ export default async function fetchStoreApi<T>(
|
||||
)
|
||||
}
|
||||
|
||||
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) {
|
||||
|
Reference in New Issue
Block a user