Slow down Loop so it waits X seconds between loops

Hi - I'm looping through a query result and try to trigger API calls with each rows data.

The problem is that I'm fairly quickly running into API rate limitations and would need some time between the loops.

Is it possible to change the code from the loop in order to add a X second delay between the loops?

I actually managed to solve this on my own (with a little help of chatGPT).

image

The highlighted code is the previous query that I'm looping through.

Adding "await new Promise(resolve => setTimeout(resolve, 2500));" makes it wait for 2.5 sec with is enought to not overwhelm the API I'm calling.

Hope this helps whoever has the same problem / maybe someone has a better solution.

4 Likes