4 ms·
> with maybe some embedded JSON to cut out the initial AJAX request That's the only hackish portion out of there, otherwise I'd agree. I rather get back what I
by giancarlostoro 8y ago
> with maybe some embedded JSON to cut out the initial AJAX request
That's the only hackish portion out of there, otherwise I'd agree. I rather get back what I expect from an endpoint not some mixture of things.
- kbenson 8y agoWell, if you're asking the endpoint for an HTML representation of something, and it responds with template portions and rules for combining them based on data (React,Vue), doesn't it make sense to respond with all the date needed to actually build it right then and there? If someone requests /users.json I return JSON. If someone requests /users.html I return a document with rules in JS for how to build the HTML based on the data (Vue) and the JSON to build it with. In both cases the JSON is the important part, the Vue stuff included in the HTML version is just a transform on that data to be applied by the client. In that respect, I think not including the desired JSON would by hacky, requiring a separate request for the actual data you requested initially.