Loop
Process a list of items by executing the same step repeatedly, handling each element one at a time in sequence.
Enabling Loop
To enable looping for a step:
- Click the step’s options menu (⋮)
- Click
Add Loop
- Enter a loop expression in the Loop Expression field that will determine how the step iterates
The loop expression determines what item will be processed in each iteration. The step will execute repeatedly, processing one item at a time until the loop expression returns a termination value.
Loop Expression
- A JavaScript expression that returns the next item to process
- Returns
null
,undefined
, orfalse
to terminate the loop - Has access to special variables:
index
: Current iteration number (starts at 0)item
: Current value being processed
Loop Output
- When loop is enabled, the step’s output becomes an array
- Each array element contains the output from one iteration
- Output array maintains the order of processing
Loop Expression Rules
Accessing Output
When a step has looping enabled, its output becomes an array containing the results from each iteration. You need to handle this array structure differently than non-looped steps:
- Each array element contains the complete output from one iteration
- The array maintains the order of processing
- You must use array methods like
map()
to access individual iteration results - Direct property access will fail since the output is now an array
Loop Termination Rules
- Loop stops when expression returns:
null
undefined
false
- Array bounds automatically handle termination:
Examples
Here are some practical examples demonstrating common loop patterns and use cases:
Parallel API Requests
Process multiple API endpoints simultaneously:
File Batch Processing
Process multiple files with consistent logic:
Troubleshooting
Common issues that may arise when working with loops and how to resolve them:
Infinite Loops
Output Type Mismatches
Remove Loop
To remove a loop from a step:
- Click the step’s options menu (⋮)
- Click
Remove Loop
Was this page helpful?