I have a couple of items that I need to query a 3rd party API for and said API has a call limit of 5 calls per second. I need to somehow throttle my calls to the API to a maximum of 5 calls per second.
So far I've just used Promise.all() on an array of promises, where each promise sends a request to the API and resolves when the API responds with the HTTP status code 200 and rejects when it responds with some other status code. However, when I have more than 5 items in the array, I risk that the Promise.all() rejects.
How can I limit the Promise.all() call to 5 calls per second?