apilayer / positionstack

Free, Real-Time Geocoding & Maps API
https://positionstack.com
33 stars 7 forks source link

No way to use with javascript - browser. #10

Open FlauzerOriginal opened 1 year ago

FlauzerOriginal commented 1 year ago

Hi, I just signed up to test your product. In particular forward and reverse api. I'm reading the documentation (https://positionstack.com/documentation), and issuing RUN API requests...but also writing my own code, I have the same problem.

At every test, I got this result....

{"error":{"code":"https_access_restricted","message":"Access Restricted - Your current Subscription Plan does not support HTTPS Encryption."}}

CODE:

`const Http = new XMLHttpRequest();
const url='http://api.positionstack.com/v1/reverse?access_key=<MyAPI>&query=<lat,long>';
Http.open("GET", url);
Http.send();

Http.onreadystatechange = (e) => {
    console.log(Http.responseText)
}`

BUT, with simple code in vbscript this works...

Dim o Set o = CreateObject("MSXML2.XMLHTTP.3.0") o.open "GET", "http://api.positionstack.com/v1/reverse?access_key=<MyAPI>&query=<lat,long>, False o.send MsgBox o.responseText

Do you have any tips or tricks to work with the browser (javascript) ?

Thanks in advance.


ritvikkolhe commented 1 year ago

Try using a different HTTP client library such as Axios or Fetch in your code instead of XMLHttpRequest. These libraries may have better support for HTTPS encryption and may work better with the Positionstack API. If none of these work you might need to upgrade your subscription plan to one that supports HTTPS encryption.