Closed leffot closed 2 years ago
Thanks for the detailed issue @leffot! 🙌
I have debugged this and looks like it's related to this debounce https://github.com/bigcommerce/storefront-data-hooks/blob/abbe17a37d36e57ad1183d230d04ebbbb6dfefa0/src/cart/use-update-item.tsx#L54
useUpdateItem
, it will failI would remove it from the library and let the users decide if they want a debounce or not. (cc @jivewise)
Thanks for the quick reply @jorgemasta! That makes sense. I appreciate you looking into it.
The latest beta release includes this fix. You can try it running yarn add @bigcommerce/storefront-data-hooks@beta
.
Closing because it will be included in the next release.
Thanks @jorgemasta. Works like a charm!
Using
Issue When a user tries to increment a product’s inventory beyond the maximum available, an error is thrown:
Uncaught (in promise) Error: An unexpected error ocurred with the Bigcommerce API
.Of course, we expect an error to be returned in this instance, since the user should not be able to add more inventory to their cart, as they’ve already hit the limit.
But what’s odd is that this error cannot be caught, which means we can’t pass the error along to the user.
Our Incrementer component looks something like this:
The call to
updateItem
is wrapped in atry...catch
, so conceivably the error should be caught. Is there some other approach we’re supposed to take here?And in fact it appears that
updateItem
doesn’t even return a promise, because if we try this:Then
res
is immediately logged asundefined
, and the error is thrown a few seconds later. Thoughts?