Calculate using a REST API within a repeating List

Hi,

I have a repeating large list that contains an image and a title.

The list is bound to a Data variable (artworks_list) which is connected to a Data resource filled using a REST api.

The title is current.artworks_list.title so this works file and the list displays a list of the titles as expected.

The image URL, on the other hand, is not contained in artworks_list. To get the image URL I need to make another API call using current.artworks_list.imageAPI_url and get the image URL from the returned JSON. (current.artworks_list.imageAPI_url is obviously different for each piece of artwork in the list).

To summarize, the image URL needs to be retrieved on the fly because it isn’t part of the artworks_list dataset.

How can I get this additional piece of data (imageURL) without resorting to an external solution? (I managed to get this to work by creating an Integromat Webhook and routing current.artworks_list.imageAPI_url through that, but it’s not practical cost wise because Integromat charges per operation and that ramps up very quickly.

Thanks.

Hi, here’s a quick pseudo implementation of something like this, not all the formulas are sound, but hope you get the general idea how to do it:

  1. Have a page variable ready for your complete dataset including the image URLs (here fullData)
  2. Pull the whole dataset, and set values of fullData from its output – you can use MAP, for example MAP(outputs["Get artworks"], {id: item.id, imgUrl: ""}) to initialize the imgUrl as empty
  3. Have another list type page variable for the values that you want to loop through (here idList)
  4. Check if idList is empty
  5. If not, make HTTP request with idList[0].id to get the corresponding image URL
  6. Add this to fullData list again using MAP – if the ID matches the id you sent, use SET_KEY to add the correct imgUrl to the list item, otherwise just return the item itself
  7. Remove first item you just used from idList
  8. Repeat operation if there are values left in idList, otherwise you should have all imgUrls populated in fullData list, and you can repeat your items from there.

1 Like

@Mari

Thanks for your detailed response. I really appreciate your time and effort!

I’m an AppGyver newbie and your proposed solution is quite complex and hard for me to grasp off hand so I’ll take some time to try and work through it and let you know how I succeeded.

Thanks!

@Mari

Great success. I managed to accomplish the task thanks to your roadmap!

I think it would be nice if AppGyver had a “before show” event which would be triggered before an item is about to be rendered. This would make accomplishing tasks similar to the one described above much easier.

Thanks!

@John_Galt, great to hear that you got it to work and thanks for the feedback! You can submit feature requests directly to the development team in the tracker here: https://tracker.appgyver.com/