I am developing an API for my angular app.
I display some general data on the homepage and also have a slider that displays boosted items. Now the question is, is it appropriate to send multiple API calls to load the homepage. One request gets general list of items. The other request grabs list of boosted items.
@prido Yes. Build your API endpoints around resources and now how a particular client is going to be consuming them. Otherwise you’re constantly going to be re-designing (and breaking) your API endpoints every time you make a UI change in your Angular app. And the nightmare will only increase if you then bring on additional consumers, say mobile apps.
Sending multiple requests to get data on each element of your page is fine, it will be reusable and easy to test/debug. I think you just need to check if multiple requests make your app slow.
I would also consider caching those requests so the load on your server is not that high if you have a lot of traffic.
Another thing to consider is if you want to have 1 request to get all data, make a route that collects data on all different routes so other routes still are separated from each other but now you have a dedicated route for your homepage so if you change boosted items route/function you won't have any duplicate codes.
Same on your Angular App. Create a separate function that calls other function that renders the data on your page and pass your received data on those functions. Again, you don't want to create another code that renders those data, just re-use them and create a "middle-man" that connects them. Hope that makes sense.