jQuery check country or ip and fire action

PHOTO EMBED

Thu Jul 21 2022 09:52:45 GMT+0000 (UTC)

Saved by @mickeldav #javascript #jquery

	fetch('https://api.ipregistry.co/?key=tryout')
    
    .then(function (response) {
        return response.json();
    })
    .then(function (payload) {
        console.log(payload.location.country.name);
        var cntr = payload.location.country.name;
        if( cntr == "United States" ){
           
            jQuery("div#gplaybtn .banner__btns a:nth-child(2)").attr("href", "https://play.google.com/store/apps/");
             //alert(cntr);
        }
    });
content_copyCOPY