DEV Community

Discussion on: Some Best Practices of Javascript for clean and better code quality...

Collapse
 
rishit profile image
Rishit Bansal • Edited

Nice Post! One thing I would like to point out, Parallel API calls can be detrimental sometimes if you go overboard with them. Say my function did 5 API calls simultaneously, and this function was called at a high rate in my code you can actually end up causing a lot of load on the target server. Moreover, most APIs also have rate limiting setup and successive requests might be blocked.

A way to circumvent this is to use a Queue of promises and process promises from the queue at a fixed concurrency level (say 2 at a atime, or 3 at a time). P-queue is a great library to achieve this.