user-1
(User 1)
1
This topic was automatically generated from Slack. You can find the original thread here.
Hi everyone,
How can I create a Node.js step that makes a post request to an array but with 5 second wait between each value in an array?
The reason is not to get error for rate limitation on the 3rd party API.
user-1
(User 1)
2
Basically for each item in the array sends the request and wait a few seconds before proceeding to the next one?
user-1
(User 1)
4
I know how to build it but I don’t know how to put the delay between each item in the array
user-1
(User 1)
5
There’s a very simple await delay() I’ve used in the past, I’ll send it soon (you can also ask chat GPT I’m sure they’ll give a working example)
user-1
(User 1)
6
I’ve used this before
const delay = (ms) => new Promise((res) => setTimeout(res, ms));
await delay(5000); // 5s
user-1
(User 1)
7
I appreciate it.
I just tried and it works like a magic
user-1
(User 1)
8
check out the code formatting in Discourse - it includes the HTML tags (making the code unusable)