function getMyIP() { fetch('https://ipv4.myip.coffee') .then(response => response.text()) .then(ipv4 => document.getElementById('ipv4').textContent = ipv4) .catch(err => { console.log(err); document.getElementById('ipv6').textContent = `Not available!` }); fetch('https://ipv6.myip.coffee') .then(response => response.text()) .then(ipv6 => document.getElementById('ipv6').textContent = ipv6) .catch(err => { console.log(err); document.getElementById('ipv6').textContent = `Not available!` }); } document.addEventListener('DOMContentLoaded', () => { getMyIP(); });