0

I am trying to send several almost identical requests (fetch). The requests themselves should be sent shortly after each other, but not all at once (rate-limit). My current approach:

for (let a of alist) {
            a = a.replace(/\s/g, '');  
            sleep(2000).then(()=> {
                fetch(...something with a);
            });
        }

All requests are sent about the same time and I get a rate-limit

My sleep-function:

function sleep(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
  }

0 Answers0