In an integration, we are able to connect to an API using custom JS but bulk requests are not available and we don’t want to use up a lot of tasks.
The solution uses the code action almost as far as its timeout limit will allow, resulting in great optimization while allowing for variability in API response times. This solution will generally need to be used along with while loops and variables.
Process large numbers of requests sequentially, staying under the time limits of the Workato JS action (30 seconds).
Timer function snippet – runs 28 seconds, allowing 2 seconds to bail:
var executionStart = Date.now()
var keepExecuting = () => {
return (Date.now() – executionStart) < 28000
}