[Solved] Google Places API (JSON) and List Viewer

Hi,

I have trouble getting data from the Google Places API onto a list in my app.
The list stays empty.

It works with a different web API (api.obenbrewerybd.org) and I get data in the list, so there must be a problem with the data I get back from Google.

The Google Places API URL works, as I get results when opening it directly in the browser (see screenshot).
I want to get the results from “name” in the list in the app.

Can anyone help me here please, as I am stuck.

Thanks!

1 Like

Hi,

To access the JSON node, you must specify the full path from the root node, as with file names. If you specify myFile.txt, the computer will not find it, because it is not clear in which folder this myFile.txt is located.

1 Like

Hi,
thanks for your help!

I don’t really understand what I have to do now.
Is this something I can do with Thunkable?

1 Like

@Joey, the problem is caused from your blocks - get property “name” of object “j”. This is wrong because you give the incorrect path to access the “name” property.

I look the JSON file you attach, you can try to do like this to access “name”:

2 Likes

@joannietw thanks, I tried that but it still does not work and the list stays empty.

Do you have any other idea? I think we’re almost there.

Your help is really appreciated!

1 Like

You are trying to move a 200 kg barbell at a time. It is very difficult. Try to move the bar in parts. To do this, remove the “for each item” loop and try to get the value of the “name” field. If this happens, then after that you can try to use the cycle.

But you can do it easier - give us this JSON file so that someone can solve this problem for you.

1 Like

Here is an example JSON response from the Google Places API:
https://developers.google.com/places/web-service/search#nearby-search-and-text-search-responses

Here I would like to get for example the name in line 13:
“name” : “Rhythmboat Cruises”

Thanks!

1 Like

Check it

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

2 Likes

Thanks.
I checked this project and I have no idea what to do now?
I played around with it, but never got it to work with my API URL.
I have not much experience with APIs. Can you please tell me what I have to do to make this work?

1 Like

Does my project work for you? After clicking on the button you got the value of the desired field? If the example works, then you need to figure out why it is these blocks that are used in it and make the blocks for your decision.

1 Like

Hi Joey,

actech’s app does a perfect job in retrieving the ‘name’ property of your JSON response.
If you’re new to APIs, try checking out this tutorial I just wrote that talks the reader through using a Location API to get the name of the country where a given latitude/longitude point is located.
Because they’re both based around Location APIs, you might find the information in it useful for understanding your API. :slight_smile:

2 Likes

@actech Yes it works, thanks.
@jane Thanks for this link. This looks like what I need to get a better understanding of how APIs work and to make my project work. :slight_smile:

3 Likes

Nice topic… I will use it

3 Likes

@jane now it works for me! :sweat_smile:
I followed your tutorial step by step and now I finally understand how the blocks work here. Thanks again!

3 Likes

I’m so glad to hear it! :smile:

2 Likes