Problems with For loop!

Hi - I’m tearing my hair out with a problem and was wondering if anyone here might be able to help.

I have an Airtable spreadsheet that looks like this:

El Pastor|51.505315|-0.091193

I’m trying to create and display a list which shows the distance from an inputted location to each of these restaurants, and the name of each restaurant. I’m doing this using the Google Maps API.

The output I get from this in the app is a list of the correct distances to each restaurant, but it just repeats the name of the last restaurant 3 times. e.g.:

Xu 3248seconds
Xu 177seconds
Xu 2913seconds

The distances are correct, and displayed in the correct order. I just can’t figure out how to display the correct restaurant name for each distance! These are my blocks - if anyone can figure out what’s wrong here, that would be absolutely amazing. Thanks!

To talk you through the blocks:

  • first call the Airtable spreadsheet
  • then begin loop for each item in the list
  • the green Web_API block is using the Google Maps, using the coordinates of each restaurant from the spreadsheet
  • the purple API block gets the response; and then saves as a list the time in seconds to each restaurant (the big pink thing) and the name of the restaurant (this latter bit is what’s broken).

If you give a link to your project, then I’ll look it up. - thanks!


The problem is that the Web_API.Get uses slow asynchronous call. A cycle has worked, as Web_API.Get have not had time for it and, therefore, displayed the latest reading. You will need to modify the algorithm so that the next call to Web_API.Get happened only after the completion of the previous call.

Here it is necessary to use recursion, as Mark showed.

I will think over such a block

1 Like

Check it

1 Like

Amazing - seems to work perfectly. Thanks so much for this - absolute lifesaver!

1 Like

Please can you share how you resolved the issue. I have a similar issue with my own project.


Unfortunately, the project for this link I have not survived. If you give a link to your project, I will try to see it.


Here’s the link-

After clicking on your link, I see a blank white screen.

I just made it public. Please, can you try again?

Project opened

On which screen and in which block is the code that does not work correctly? There are a lot of duplicate blocks in your code, an incomprehensible delay of 10 seconds, a lot of unnecessary variables, no checks for errors when getting data from the API. Try to simplify the code. The more blocks - the more mistakes.