Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fetch('https://api.ipify.org?format=json')
- .then(response => response.json())
- .then(data => {
- const ipAddress = data.ip;
- console.log(`IP Address: ${ipAddress}`); // Вывод IP-адреса пользователя в консоль
- // Запрос к геолокационному сервису для получения местоположения
- fetch(`https://ipinfo.io/${ipAddress}/geo`)
- .then(response => response.json())
- .then(location => {
- console.log(`Location: ${JSON.stringify(location)}`); // Вывод географического местоположения
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment