External API requests depending on the number of records returned in previous response

Options
aleksis
aleksis Member
edited October 2023 in ? Transforming data

Hello,

I am struggling with adjusting my function stack to do external API requests depending on the number of records returned.

I have built an app that fetches bank account details. It is working fine with a single account

where first API gets the account number (if 1 account is returned it is fine):

and second API does a call using the account number (921cdef…) to the bank fetching account details like balance, currency, name, etc.

I am having problems when on first API multiple accounts are returned like this

it does not work because of dot notation both accounts are combined in a single line. I would need here to split the accounts one by one and do an external API call for each of the accounts depending of how many there are. It could be that the person has 1 ; 2 ; 5 or more accounts.

How can I create a function to "separate accounts one from the another and then do an external API request for each one to fetch account data"?

Or is there a better way how to do it?

Best Answer

Answers

  • aleksis
    aleksis Member
    Options

    Is it possible to do an external API call via "For Each Loop" function? Meaning, I'd like to do an external API call for each record in the array of accounts separately.