Elson TC
Feb 1, 2022

--

Removing the lines 17 and 19 on first solution would do the trick. Honestly, in the real world you could have API endpoints to support various type of requests:

/people => to get it all
/people/:id => to get a single one
/people?ids= => to get comma separated specified id

If I need to request 1000 people by specific id I would extend the server API and not the client way to request things. Thats because you are still making 1000 requests instead of a single one which is not ideal neither for the client or server.

How would handle error? Do you need to reformat data on receiving them?

--

--

Elson TC
Elson TC

Written by Elson TC

Software Engineer sharing knowledge, experience, and perspective from an employee and personal point of view.

Responses (2)