Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



I 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/


> 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.ht...


REST is the architectural style of the web, so returning HTML is the primary use case.


> 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.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: