Changed around line 1
- document.addEventListener('DOMContentLoaded', () => {
- const form = document.getElementById('lookupForm');
- const loader = document.getElementById('loader');
- const results = document.getElementById('results');
- const error = document.getElementById('error');
+ document.addEventListener("DOMContentLoaded", () => {
+ const form = document.getElementById("lookupForm");
+ const loader = document.getElementById("loader");
+ const results = document.getElementById("results");
+ const error = document.getElementById("error");
- document.getElementById('country').textContent = data.country;
- document.getElementById('city').textContent = data.city;
- document.getElementById('region').textContent = data.region;
- document.getElementById('timezone').textContent = data.timezone;
- document.getElementById('isp').textContent = data.isp;
-
- loader.classList.add('hidden');
- results.classList.remove('hidden');
- error.classList.add('hidden');
+ document.getElementById("country_name").textContent = data.country;
+ document.getElementById("city").textContent = data.city;
+ document.getElementById("region").textContent = data.region;
+ document.getElementById("timezone").textContent = data.timezone;
+ document.getElementById("isp").textContent = data.isp;
+
+ loader.classList.add("hidden");
+ results.classList.remove("hidden");
+ error.classList.add("hidden");
- loader.classList.add('hidden');
- results.classList.add('hidden');
- error.classList.remove('hidden');
+ loader.classList.add("hidden");
+ results.classList.add("hidden");
+ error.classList.remove("hidden");
- form.addEventListener('submit', async (e) => {
+ form.addEventListener("submit", async (e) => {
-
- const ipInput = document.getElementById('ipInput');
+
+ const ipInput = document.getElementById("ipInput");
-
+
- loader.classList.remove('hidden');
- results.classList.add('hidden');
- error.classList.add('hidden');
+ loader.classList.remove("hidden");
+ results.classList.add("hidden");
+ error.classList.add("hidden");
- const response = await fetch(`https://ipapi.co/${ipAddress}/json/`);
+ const response = await fetch(
+ `https://api.ipgeolocation.io/ipgeo?apiKey=68f7a83f9d84466bb5054f6b3e8da8a6&ip=${ipAddress}&fields=city&output=json`,
+ );
-
+
- throw new Error('Invalid IP address');
+ throw new Error("Invalid IP address");
- country: data.country_name || 'N/A',
- city: data.city || 'N/A',
- region: data.region || 'N/A',
- timezone: data.timezone || 'N/A',
- isp: data.org || 'N/A'
+ country: data.country_name || "N/A",
+ city: data.city || "N/A",
+ region: data.region || "N/A",
+ timezone: data.timezone || "N/A",
+ isp: data.org || "N/A",