One approach could be to fetch all user data and store it in the client-side memory within the Angular application, then simply retrieve the corresponding user for each post.
This method would work well for a small number of users, like in this case with only 10 users. However, in a more realistic scenario where there are numerous users, this approach would not be practical.
In a real-world situation, storing all posts or users locally would also not be feasible due to the potentially overwhelming amount of data. It would lead to memory overload and crashing issues on the user's browser.
Therefore, in an actual application, it would be ideal to display only a limited number of posts at a time, such as the most recent 100 posts or a specific number of posts per user. Pagination would need to be implemented to load more content from the server as needed.
Regarding your initial query, I recommend one of two solutions:
If you have control over the API, ensure that user information is included with each post response.
If API control is not possible, gather unique user IDs for the displayed post page and request user details from the server specifically for those IDs. Ideally, consolidate these requests into a single batch call. If batch processing is unavailable, individual API calls per user ID would be necessary.
By following this method, you can link posts to their respective users while managing a manageable number of users associated with the current post display.