How to delay api calls in a loop to prevent throttling from AWS
using the javascript SDK that aws provides. I have a loop that get executed every 16 seconds, in this loop i get the state of each pipeline I have, which comes out to about 20 pipelines and 20 api calls. My problem is that when this loop gets executed I sometimes end up with some throttling errors from AWS on some states i try to fetch. I need to some how add like a 1 or 2 second delay before each call to getPipelineState so im not met with throttling errors below is the code Create a new delay function that returns a promise that is resolved after X milliseconds. Then just await that, here's an example. You can either call async map function with index and await sleep(index*2000) inside or chain promises through array like this: By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies...