I'm wondering what's best practice in next use case: I'have a view that displays data for 3 resources User, Company, and CompanyType (chosen in select, can be added dinamicaly so it's not enum). What is the best way to retrieve data: 1)Call API 3 times to get data: /user/id/, /user/id/company, /company-types 2)Or creating single-route (something like viewModel) to handle data gathering?

If it somehow matter, API is in Laravel and front end application is written in AngularJS

  • 1
    In most cases just start with scenario 1. Then when that works you can always introduce an additional layer which groups them for example for performance when needed. In most cases it will work just fine. This works also well because you get really good insight in what that more optimal interface should contain. Deciding that upfront is quite difficult. It's the most simple implementation and it confirms to important terms like YAGNI, Premature Optimization and lots of others. But most important you get simple software. Oct 6, 2016 at 14:19

1 Answer 1


If the resources to show are independent resources (and not actually sub-sections of one resource) and the list to choose those resources from can change dynamically, then the most robust implementation is to call the API separately for each resource.

The advantage of separate calls is that you don't need to create any logic to aggregate/split a collection of unknown but different resource representations.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.