by MatthewPhillips · 14y ago · 0 comments
In the real world the HTML output is not like JSON or XML as you told.
It is used to show data to a human and most of the time it contains a lot of elements that are not related with the resource data even if it is not representing more than a resource in the same page.
The interaction with a human doesn't happen in the same way as with another system.
My experience might be different than yours, but very often my html views quickly end up needed more than 1 resource to render and now I need to fetch data just for the html templates. The same data set isn't needed when returning json or xml and the API end points exposed for data consumption are often quite different. That said, in some cases, I agree that your approach would work.