Replies: 1 comment 1 reply
-
|
Hey, that's a very hot topic that I still hope to convince 1cg about, someday! 😎 See issue #1619 for more discussion on the matter The For now, you'd likely want to use the Also, note that there is an open issue in the extensions repo to add the ability to specify a different As for my very personal opinion, I definitely think that returning 200 codes to render errors is not the way htmx should be used, HTTP status codes were invented for a reason, it'd be a shame not to use them! Hope this helps! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Background
By default, htmx doesn't perform swaps on error responses from the backend (i.e. status code 4xx or 5xx).
One could use the Response Targets extension and its
hx-target-errorattribute to facilitate this, but in vanilla htmx it doesn't seem to be the intended way to use htmx, requiring users to hack something together with error event handling, change the global error handling configuration etc.In at least one issue discussion, there was a suggestion by an htmx collaborator to just return 200 responses from the backend for "anticipated" errors, with error messages included somewhere in the HTML to be swapped.
My questions
Are these responses with 200 status codes but error messages inside the returned HTML how htmx is "meant to" be used?
If so, how does that fit to its implicit mission (given some of the essays on the website) to be RESTful? Or is the way status codes are used in JSON-RPC-style "REST" another distortion of the original REST idea?
Beta Was this translation helpful? Give feedback.
All reactions