merhaba birde böyle denermisin
const targetCountry = 'TR';
fetch('https://api64.ipify.org?format=json')
.then(response => response.json())
.then(data => {
const userIP = data.ip;
return fetch(`https://ipinfo.io/${userIP}/country?token=79e4ca65674d68`);
})
.then(response => response.text())
.then(country => {
const targetElement = document.querySelector("#test");
if (country.trim() === targetCountry) {
console.log('çalıştı');
targetElement.textContent = 'çalıştı';
} else {
console.error('hata');
targetElement.textContent = 'hata';
}
})
.catch(error => {
console.error('IP alınırken bir hata oluştu:', error);
});