Iterate through a list using a For loop

A common Flows design pattern involves getting a response from a request that returns a list, then processing each item in the list. You can do this by constructing a loop with a For block. A For block requires an array as its input. Blocks such as List, Get Variable, Evaluate, and Select can return an array, but the response from an HTTP Request block typically doesn’t. You can use TypeScript in an Evaluate block to transform a response into an array.

Recipe

The following recipe shows how to use an Evaluate block to manipulate the response from an HTTP Request to create an array:

  1. Create a flow module and add an HTTP Request block.

  2. In the HTTP Request block, create a GET request with the following URL:

    https://openlibrary.org/subjects/love.json?limit=5
    

    This gets a list of five book titles, along with other response data.

  3. Connect an Evaluate block to the HTTP Request block’s Success port. Rename the value1 input items, then click its Enter path… field and add an inline Select block. Set the Select block’s path to body.works.

  4. To make an array from the selected part of the previous block’s response, enter this code in the Evaluate block:

    items.map((work: any) => work.title)
    

    This creates an array of the book titles.

  5. Connect a For block’s List port to the Evaluate block’s Result port.

  6. Connect an Evaluate block to the For block’s Item port and rename the value1 input item. Then enter this code:

    item.toUpperCase()
    

    This capitalizes all the letters in the titles.

  7. Connect a Collect block to the Evaluate block’s Result port. This will put the capitalized items back into a list.

Try it out

To see this recipe’s completed flow, check out Cookbook: Iterate through a list using a For loop. You can also clone this flow to your workspace to experiment with it.

This recipe shows one example of how to make a loop in Flows. For more examples, see the following:

Last modified: 2025/09/09