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

SPIKE Investigate how the response to the request is generated and how the response to a request is processed on client side. #189

Open
sabina-talipova opened this issue Jan 31, 2024 · 1 comment

Comments

@sabina-talipova
Copy link
Contributor

Description

In a CMS, there are several approaches to how requests are processed and responses to a request are sent, as well as how an error response is sent.
This mainly applies to AJAX requests. In some cases, a 403/404 error is sent directly depending on the request, but the error message itself is not sent. In other cases, we send status code 200 and an error directly in the body of the response, most often this is a response in graphQL format, where the error is part of the HTML fragment.
This also applies to queries that return a specific result but do not contain a message.
What is it for. Sometimes on the client side it is necessary to process the server message and provide the user with confirmation that the request was successful or display an error message.
There are probably components that still do not provide feedback to the user in the form of a toast message or any other message.

It is necessary to conduct a review and determine how the response to the request is sent. If it is possible to fix existing functionality, then perhaps it should be fixed. If this is not possible, then a specific approach to handling requests should be developed and used to ensure consistency in the response format, thereby allowing some functionality to be reused.

@emteknetnz
Copy link
Member

emteknetnz commented Jan 31, 2024

https://github.com/silverstripe/developer-docs/pull/445/files is the recently merged best practice doc on creating API endpoints in the CMS, so things should follow this standard going forward

That doc doesn't give too much guidance on the exact HTTP status codes, though that's because they're standard and there's plenty of other references that spell this out e.g. https://developer.mozilla.org/en-US/docs/Web/HTTP/Status

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

2 participants