19 lines
446 B
JavaScript
19 lines
446 B
JavaScript
async function testGeoIP(ip) {
|
|
try {
|
|
const response = await fetch(`http://ip-api.com/json/${ip}`);
|
|
const data = await response.json();
|
|
console.log(`IP: ${ip} => Country: ${data.country}, City: ${data.city}`);
|
|
} catch (error) {
|
|
console.error(`Error for ${ip}:`, error.message);
|
|
}
|
|
}
|
|
|
|
async function run() {
|
|
const ips = ['8.8.8.8', '41.207.160.0', '1.1.1.1'];
|
|
for (const ip of ips) {
|
|
await testGeoIP(ip);
|
|
}
|
|
}
|
|
|
|
run();
|