How do I use setTimeout within a Node.js code step?

This topic was automatically generated from Slack. You can find the original thread here.

gregonarash : is there a way to use settimeout inside of nodejs step? Adding await does not really await for the timeout to resolve. I am trying to execute 2 url calls spaced out by 30 seconds.

Dylan Sather (Pipedream) : there’s an action - Wait N milliseconds - that wraps this logic. See this workflow. Code is:

await new Promise(resolve => setTimeout(resolve, milliseconds))

gregonarash : Thank you so much! This was not obvious for me!

Dylan Sather (Pipedream) : async / await and Promises are hard, took me years to really grok

Dylan Sather (Pipedream) : and still don’t understand 100%!

Dylan Sather (Pipedream) : this is a great deep dive if you ever want a fun read: Asynchronous Programming :: Eloquent JavaScript

gregonarash : funny enough I am on an earlier chapter of this book…

Dylan Sather (Pipedream) : haha nice. I haven’t read the whole thing but I like the writing