2

So let's say I have a typical REST server that serves some data in a very specific manner, like: GET accounts, GET prices, GET inventory, GET settings, GET user_history, etc...

A single view, let's say, needs to fetch N different specific resources like this. What's the best technique/library/pattern for combining N HTTP requests into one without too much hassle?

Maintaining the "REST" idea would require writing new server code for every view because no two views would need the same set of resources. Doing this would become unnecessarily cumbersome in my opinion. I guess the only way that makes sense is to roll your own DSL that presents your data requirements to the server.

What's the easiest alternative to writing new response code for every possible combination of a given view's resource requirements?

  • 1
    What do you mean by 'combine'? Do you mean group all of the requests into a single HTTP request and request that information? Or do you want a pattern that allows you to easily navigate a group of results from asynchronous operations? – Dan Jul 26 '15 at 13:28

1 Answers1

0

You say this is a rest service, all you need to do is getting information, Why not issue a jsonp request?

issue a jsonp request for every get that you need, instead of writing a new response code for each and every get. It will save you alot of code and will enhance performance.

In conclusion, I would send a jsonp request to the server (given it's an external server of course) in order to get all the data that I need, while issuing ajax calls to the server.

issuing jsonp request to the same domain using .NET

Community
  • 1
  • 1
Barr J
  • 10,636
  • 1
  • 28
  • 46