Skip to content

Fix/product store response handling#407

Merged
Aamod-Dev merged 6 commits into
niharika-mente:mainfrom
hashhhh-16:fix/product-store-response-handling
Jun 23, 2026
Merged

Fix/product store response handling#407
Aamod-Dev merged 6 commits into
niharika-mente:mainfrom
hashhhh-16:fix/product-store-response-handling

Conversation

@hashhhh-16

Copy link
Copy Markdown
Contributor

Summary

Improves error handling in deleteProduct and updateProduct by checking res.ok before attempting to parse JSON responses.

Changes

  • Added res.ok validation in deleteProduct.
  • Added res.ok validation in updateProduct.
  • Return a meaningful error message when the server responds with a non-success status.
  • Prevent res.json() from throwing when the server returns a non-JSON error response.

Why

Previously, both functions called res.json() immediately after fetch(). If the server returned an HTML error page or another non-JSON response, res.json() would throw a SyntaxError, which was caught and incorrectly reported as a network error. This change preserves the actual request failure information and aligns the behavior with the existing error-handling pattern used elsewhere in the store.

closes #350

@vercel

vercel Bot commented Jun 22, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the niharika-mente's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Aamod-Dev Aamod-Dev merged commit 2400a70 into niharika-mente:main Jun 23, 2026
1 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: deleteProduct and updateProduct store actions swallow real error messages

2 participants