API Data in List Viewer

api
listviewer

#1

Hello,

I am a complete beginner with Thunkable but got quite a lot experience with other tools.
I am trying to list API-Data in a list viewer. So far, I managed to get the Data from the API but there is only one item being displayed in the list viewer. I know this is due to the “get last or get first of” in the “in list item” but I have no idea how to loop through the response-data of the API. I tried different things but nothing worked.
The json-data looks like this:
{
“response”: {
“results”: [
{
“Adresse”: “Grinzinger Str. 50, 1190 Wien”,
“Bewertungen”: 20,
“Name”: “FRANCESCO Grinzing”,
},
{
“Adresse”: “Grinzinger Str. 1, 1190 Wien”,
“Bewertungen”: 2,
“Name”: “L’Osteria Wien Grinzing”,
},…

My block logic looks like this:


Please help me, to get all Data displayed in the grid viewer.
Thanks, Stefan


#2

Hi,

“results” is an array of objects, and arrays are looped through “for each item in list” block.


#3

Hello,

thanks for your answer. I know, that its an array of objects but I need help looping through it…it just doesnt work, because I dont know, how to do it.

Can you help me?


#4

If you give me a link to your project, then I will help.


#5

https://x.thunkable.com/copy/aa7ccb82b5dcf48e32b30eafa21fac80


#6

Check it.

https://x.thunkable.com/projects/5bee81b8da9275432c5f322b/project/properties/designer/


#7

Thank you very much for your help!!! :slight_smile:


#8

actech - your solution is great for data that is in a list within a property, but I’m trying to apply this concept to a data set that is a list from the very first part of the object.

ex: http://dataservice.accuweather.com/locations/v1/cities/search?apikey=9KUjWtqGJtYd7CAEz5EqkpUziLrjI6XN&q=boston

From this data I am trying to grab the latitude and longitude of just the first city listed. But, my solution (based on your design) is getting stuck. Here is a screenshot of my code

. (FYI: My ultimate goal is to take a user entered city and put it on the map using longitude and latitude.)


#9

You are refering to a variable I am not sure is correct, that being J

You need to be parsing the JSON, and attaching the RESPONSE instead of J. Try that.