Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug fix] commerce-sdk-react hooks missing API errors #1699

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from

Conversation

kevinxh
Copy link
Collaborator

@kevinxh kevinxh commented Mar 18, 2024

Description

See #1659

The commerce-sdk-isomorphic errors are not being catched, causing the API errors missing from query.error. This PR checks if the error is in the form of a Response, if it is, then await the json response and throw it.

Before

CleanShot 2024-03-18 at 10 58 34

After

CleanShot 2024-03-18 at 10 46 54

Question: is this a breaking change?? 馃

Types of Changes

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Documentation update
  • Breaking change (could cause existing functionality to not work as expected)
  • Other changes (non-breaking changes that does not fit any of the above)

Breaking changes include:

  • Removing a public function or component or prop
  • Adding a required argument to a function
  • Changing the data type of a function parameter or return value
  • Adding a new peer dependency to package.json

Changes

  • Serialize API response errors

How to Test-Drive This PR

  • npm start in test-commerce-sdk-react pacakge and go to the query error page

Checklists

General

  • Changes are covered by test cases
  • CHANGELOG.md updated with a short description of changes (not required for documentation updates)

Accessibility Compliance

You must check off all items in one of the follow two lists:

  • There are no changes to UI

or...

Localization

  • Changes include a UI text update in the Retail React App (which requires translation)

@kevinxh kevinxh requested a review from a team as a code owner March 18, 2024 17:51
@kevinxh kevinxh changed the title [Bug fix] commerce-sdk-react hooks query.error is always null [Bug fix] commerce-sdk-react hooks missing API errors Mar 18, 2024
shethj
shethj previously approved these changes Mar 18, 2024
@alexvuong
Copy link
Collaborator

Should we do the same in useMutation.ts?

    const authenticatedMethod = useAuthorizationHeader(hookConfig.method)

@kevinxh
Copy link
Collaborator Author

kevinxh commented Mar 22, 2024

Had a chat with @bendvc and we both agreed that maybe this change should be done at the commerce-sdk-isomorphic level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants