I have an array of endpoints I'd like to query like so:
const apiList = ['/api1', '/callme', '/thisonetoo']
Using axios, a promise based library, I can dynamically generate a promise by mapping the array ->
Promise.all(apiList.map(name => promiseGet(name))).then(res => ...)
This works fine... but it calls the server too fast, and some of the apis get denied, which causes the entire program to mess up.
Is there a way to throttle / debounce and wait 500ms before creating or calling the next endpoint?
Limiting the amount of Promises open isn't enough it seems. I have to perform some sort of "sleep" operation and wait a little bit before calling the next api endpoint in the array.