added ipinfo.is api , fixed innertext on html

This commit is contained in:
acidburnmonkey
2025-08-07 01:20:09 -04:00
parent 45c4abc752
commit ad2bd9a426
6 changed files with 86 additions and 100 deletions
+31 -43
View File
@@ -1,53 +1,41 @@
interface ApiResponse {
method: string;
ip_info: {
as_domain: string;
as_name: string;
asn: string;
continent: string;
continent_code: string;
country: string;
country_code: string;
ip: string;
};
}
const requestOptions = {
document.addEventListener('DOMContentLoaded', function () {
const requestOptions: RequestInit = {
method: 'GET',
headers: { 'Content-Type': 'application/json' },
};
};
fetch('/doxme/', requestOptions) //call api
fetch('/doxme/', requestOptions) //call api
.then((response) => response.json())
.then((jsonResponse) => {
const user_ip = jsonResponse.ip_info.ip;
const user_country = jsonResponse.ip_info.country;
const user_region = jsonResponse.ip_info.country_code;
const user_ip: string | null = jsonResponse.ip_info.ip;
const user_country: string | null = jsonResponse.ip_info.country;
const user_region: string | null = jsonResponse.ip_info.country_code;
// Update the HTML elements with the fetched information
document.getElementById('ip').textContent = `${user_ip}`;
document.getElementById('country').textContent = `${user_country}`;
document.getElementById('region').textContent = `${user_region}`;
// Update the HTML elements with the fetched information
document.getElementById('ip').textContent = `${user_ip}`;
document.getElementById('country').textContent = `${user_country}`;
document.getElementById('region').textContent = `${user_region}`;
console.log('user_ip:', user_ip);
console.log('couintry:', user_country);
console.log('region:', user_region);
console.log('user_ip:', user_ip);
console.log('couintry:', user_country);
console.log('region:', user_region);
// IPIS api
const city = jsonResponse.ipis.location.city;
const state = jsonResponse.ipis.location.state;
const isp = jsonResponse.ipis.company.name;
const longitude = jsonResponse.ipis.location.longitude;
console.log('city', city);
console.log('state', state);
console.log('isp', isp);
console.log('longitude', longitude);
document.getElementById('city').textContent = `${city}`;
document.getElementById('state').textContent = `${state}`;
// document.getElementById('isp').textContent = `${longitude}`;
})
.catch((error) => {
console.error('Error fetching IP information:', error);
});
fetch('http://ip-api.com/json/')
.then((response) => response.json())
.then((data) => {
const user_city = data.city;
const user_isp = data.isp;
console.log('user_city', user_city);
console.log('user_isp', user_isp);
document.getElementById('city').textContent = `${user_city}`;
document.getElementById('isp').textContent = `${user_isp}`;
})
.catch((err) => {
console.log('idk error', err);
console.error('Error fetching IP information:', error);
});
});