Geolocation via an API

Oops - seems we missed to add those events :slight_smile: will add them in the next update.

But anyway as the data comes in your page will be refreshing directly with the data bindings being refreshed. But it is good to be able to handle loading failures

1 Like

Wow, you mean for a change this was not me, yeah…

a general example with headers / query for these API’s would be nice

1 Like

In my particular case i am using this as my api
<dmx-api-datasource id="api1" is="dmx-fetch" url="" dmx-param:base_currency="'GBP'"></dmx-api-datasource>

The service has a second service that can also be used
<dmx-api-datasource id="api2" is="dmx-fetch" url="" dmx-param:radius="50" dmx-param:format="'json'" dmx-param:limit="1" dmx-param:lat="-29.8255400" dmx-param:long="30.9370000"></dmx-api-datasource>

This second service can get the lat and long from the first but I would need to make sure the first call has finished loading before i can run the second, although i have made it work by just manually inputting the lat and long for test purposes.

Right now my bigger issue though is actually this

I added this to my .htaccess file in hopes but it does not seem to work as expected

<IfModule mod_headers.c>
    Header set Access-Control-Allow-Origin "*"
1 Like

@psweb okay I got it now! Great! Could be added to API Howto

Once i get this working i will make a small tutorial for anyone else as to what i managed to get working.

1 Like

add "Moesif Origin & CORS changer " extension to your chrome
then TURN ON it and success :slight_smile:

You mean just for testing purposes, i assume a chrome extension will not work if i am showing the output to multiple users? Maybe I am just very confused though.

are you using nginx on server side

Nope, I am on a CentOS linux hosting with this particular server.

Please check @psweb
you can test it

1 Like

I am clearly confused by this CORS stuff, so quick question is the CORS error something on my webserver or something on the remote webserver protecting itself.

I understand your question I wish I can tell you with my bad english :)) lets try :slight_smile:

for example;
if you are creating mobile app (hybrid) you have to upload all php files to your remote host and you can use client side javascript … CORS will check which domain request When click to any submit button on your mobile side …
it is protect your request

Perfect, that made 100% sense, thank you for that.

1 Like

CORS allows web scripts to interact more openly with content outside of the original domain, leading to better integration between web services


sorry for my bad english :)))

1 Like

Well I have tried everything i can think of on my side to connect to their secondary API service and can not get around that error.
What i do find strange and what leads me to believe that this is not on my side but the API developers side possibly is this.

This is the working one, note in the header how there is an entry for access-control-allow-origin

While on the second service the headers have no mention of this

And I get this error message
Access to XMLHttpRequest at '' from origin '' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Am I correct that this could be something on the API Providers side and not my side possibly.

You can’t access that service with XMLHttpRequest, they didn’t add the Control-Allow-Origin header. It is not you that has to add the header, the service has to add it. You could try to contact them about that.

An other solution is wait for us to finish the Server Connect version and connect with that, on the server side you don’t have the problem with CORS.


Thanks so much for confirmation @Patrick, i contacted them and they added something and now it is all working, so happy days.

Thanks again to all that tried to help with this one.

1 Like

Seems they added the required CORS header, I think a lot of people will be happy.