I want to do a website button that redirects to specific webpages based on user location. I'm using this free API ( https://ipgeolocationapi.com/ ) and did the button logic with ifs but I get this error in console "..been blocked by CORS policy: No 'Access-Control-Allow-Origin'. Any thoughts on this? I'm a JS newbie and this is my first post. Thank you for your help.
function SubmitFrm() {
  $.getJSON("https://api.ipgeolocationapi.com/geolocate", function (data) {
    var country = data.alpha2;
    if (country == "SE") {
      location.href = "https://www.nmbrs.com/se";
    }
    if (country == "NL") {
      location.href = "https://www.nmbrs.com/nl";
    } else {
      location.href = "https://www.nmbrs.com/diogo";
    }
  });
}<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="submit" name="btnSearch" value="Test" id="btnSearch" class="btn" onclick="javascript:SubmitFrm()" />