Nested Loop in Retool Workflows

I need to loop through a list of keys (e.g. AAA, BBB, CCC) where, for each key, I first call an API to create an empty file (which returns an import_id) and then immediately call a second API to upload data into that same file using the returned import_id, before moving on to the next key — what’s the best way to set this up in a single Retool Workflow Loop block?

Scenario Example:

We have 3 list, AAA, BBB, CCC.

  • 1st API being called (targetting list AAA)
  • 1st API get finished (returning import id)
  • Use this import ID to call 2nd API (target set to list AAA)
  • 1st API being called again (targetting list BBB)
  • 1st API get finished (returning import id)
  • Use this import ID to call 2nd API (target set to list BBB)

This is my block for 1st API:

And 2nd API:

Note: I already have another node containing all lists.

Hi @yeftanma

You can use a function to call the API from a code block, and it will return a response for each API call.

3 Likes