3 ms·
Excuse my ignorance, but are patterns like the one mentioned in the example in wide use? Chaining together the results of multiple AJAX calls to form a single r
by NDizzle 11y ago
Excuse my ignorance, but are patterns like the one mentioned in the example in wide use? Chaining together the results of multiple AJAX calls to form a single response? (response might not be the correct term - a single return value)
Wouldn't you just send a request to the server and have it handle things and spit out the correct response/return value? What's the need for multiple ajax calls?! I know we're obviously not using this to fetch first and last names - what's a realistic example for this usage pattern?
- dmak 11y agoVery common. RESTful architectures always give rise to this type of pattern. For example, you fetch a user id, and then you fetch all the blog posts by the user then you fetch the comments for the blog posts.
- fny 11y agoVery common in poorly designed RESTful architectures. Hypermedia-style APIs take care of this. [0] The performance advantage of lightweight payloads to an SPA gets trashed by network latency otherwise. [0]: http://jsonapi.org/ http://jsonapi.org/
- Kiro 11y agoHow would the URL for dmak's example look?
- fny 11y ago/users/1/posts?include=user,comments
- dmak 11y agoI don't think the structure of the response would be the dictating factor for a "poorly designed RESTful architecture". This response format no longer makes things RESTful because it lumps together so many different models. This format is more suited for command/presenter pattern (orchestration).
- alttab 11y agoFor real, this sounds like it simply allows front-end dev's to scour backend APIs and lace together really slow, really brittle web pages.