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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@plone/client: API requests that don't return a 2XX HTTP Status result in an exception being raised #6260

Open
JeffersonBledsoe opened this issue Aug 19, 2024 · 0 comments

Comments

@JeffersonBledsoe
Copy link
Member

Describe the bug

The current @plone/client code validates the status to be between a 200 and 300 status code. As shown in the axios docs for configuring requests, this is the default behaviour. However, this results in 'invalid' (i.e. all non 2XX HTTP status codes) reponses raising an AxiosError (e.g. AxiosError: Request failed with status code 404). Axios expects these non-valid status codes to be handled by a Promise catch handler, as shown by the Axios Handling Errors documentation. We are not handling these errors, as shown in the following code:

return instance.request(axiosConfigAdapter(method, path, options));

To Reproduce
Steps to reproduce the behavior:

  1. Follow the documentation and prepare a plone client for making requests: https://6.docs.plone.org/volto/client/index.html
  2. Make a request that will give a non-200 response (e.g. a getContentQuery to a page that doesn't exist will produce a 404).
  3. See the exception

Expected behavior

EITHER:

  • The exception is handled by the plone client a way of correctly handling the differing status codes is available for the developer using `@plone/client

OR:

  • There is documentation around how to correctly handle these exceptions by an integrator.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant