Distance matrix api not working

can Any1 help why this distance matrix of google map api is not working

Please post the full JSON response as text.

1 Like

i am pasting the link of app can u plz check it.
it is on the 4th screen distance calculator

I can look at it but I’ll need the full JSON response in order to help you! You can put the API url in a browser and copy and paste from there.

Without that, I have no idea if your blocks are correct because I can’t see the structure of the JSON.

Have you gotten this working in a browser yet? If not, then you shouldn’t be working in Thunkable yet. The first step is to make sure you can get a valid JSON response in a browser.

Because this doesn’t look like it’s going to work to me:

[image removed]

The user’s input will contain spaces and I think that will break the url.

But even if that works – and it may – you’re using zero for the list index and that isn’t valid in Thunkable. Try 1 instead. See the last part of this post:

By the way, your code (with [1] as list indexes) works fine on a mobile device. It just fails in a browser. Many APIs don’t in a browser with Thunkable.

:warning: I would recommend removing your API key from screenshots and project links unless you want people to use it!

i tried 1 index first it didnot worked later on i tried 0 index

{
   "destination_addresses" : [ "France" ],
   "origin_addresses" : [ "Germany" ],
   "rows" : [
      {
         "elements" : [
            {
               "distance" : {
                  "text" : "1,028 km",
                  "value" : 1027828
               },
               "duration" : {
                  "text" : "10 hours 52 mins",
                  "value" : 39134
               },
               "status" : "OK"
            }
         ]
      }
   ],
   "status" : "OK"
}

Your blocks work for me:

image

plz remove screenshot…thanx for ur help…it is working on mobile…i was just checking on web browser…

plz remove this screenshot …my key is visible in this…

You should be able to edit your post. Click on the 3 dots and then on the pencil.

I have deleted my screenshot but u also posted a screenshot …in which key is visible

Sorry about that, I’ve removed it.

Thanx man.