21 ms·
I'm not sure I get what you're saying? I think you're saying that having html returned from the backend "seems questionable" and is a "type of bad programming"
by latch 6y ago
I'm not sure I get what you're saying?
I think you're saying that having html returned from the backend "seems questionable" and is a "type of bad programming".
But that can't be right because that's mostly how the web works? Make a request to a server, server returns html.
Is your issue that it's partial "random" content? How does that make it worse? It's a tried and true solution. The hamburger menu in amazon.com does just that.
- Thorentis 6y agoI agree that the objection doesn't hold up given how many websites are made, but I think they mean that a REST API shouldn't be returning HTML, which is true. Unfortunately using the replace feature would mean rewriting existing APIs. Or, you could use the client side template feature of htmx which supports rendering JSON into HTML using a templating language: https://htmx.org/extensions/client-side-templates/ https://htmx.org/extensions/client-side-templates/
- recursivedoubts 6y ago> REST API shouldn't be returning HTML, which is true. No, it isn't. REST implies HATEOAS, and JSON isn't a hypertext. Calling JSON APIs REST-ful was always a mistake. http://intercoolerjs.org/2016/05/08/hatoeas-is-for-humans.html http://intercoolerjs.org/2016/05/08/hatoeas-is-for-humans.ht...
- inimino 6y ago> a REST API shouldn't be returning HTML Why do you think so? It might interest you to know that Roy Fielding defined REST before JSON was invented.
- goto11 6y agoREST is the architectural style of the web, so returning HTML is the primary use case.