Skip to content

Commit

Permalink
fix: fix error in case of empty response when deleting
Browse files Browse the repository at this point in the history
  • Loading branch information
jsapro committed Dec 21, 2023
1 parent d0427fb commit 49012e2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/contexts/cart-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,11 @@ export const CartProvider: React.FC<CartProviderProps> = ({ children }) => {
})
.catch((error) => {
console.error('Error deleting cart item:', error);
setError((prev) => {
return { ...prev, deleteCart: error.errors[0].detail };
});
if (error?.errors) {
setError((prev) => {
return { ...prev, deleteCart: error.errors[0]?.detail };
});
}
});
};

Expand Down

0 comments on commit 49012e2

Please sign in to comment.