Get Country in Yandex game

Hi
I need to get country so that I can localise my game automatically.

I tried two methods

First

pc.http.get("https://api.country.is", { "retry": true, "maxRetries": 5,json:true}, function (err, response) {
    console.log("Country response= "+response.country);
});

Second


    fetch('https://api.country.is')
        .then(response => response.json())
        .then(function (response) {
        console.log("My Country is = " + response.country);
        }.bind(this));

And both these methods I got the following error

Refused to connect to ‘URL’ because it violates the following Content Security Policy directive

Please suggest another method or suggest solution to above Error

Thanks

Works fine for me here:

Hi

Yes it works fine in playcanvas editor but when I upload it to yandex I get error

Then its more to do with either Yandex hosting or potentially the API blocking requests from Yandex domains. It’s not related to the PlayCanvas engine

Hmmm
This is the error on console.

As it’s a Content Security Policy directive error, its Yandex page/site blocking the outgoing request. You will need to talk to them or refer to the documentation in adding the API to the allowlist.

Checking
Thanks!