Cómo obtener la dirección IP en JavaScript
fetch('https://api.ipify.org/?format=json')
.then(response => response.json())
// Returns
{
"ip": "user_ip"
}
Aarush h
fetch('https://api.ipify.org/?format=json')
.then(response => response.json())
// Returns
{
"ip": "user_ip"
}
fetch('https://api.ipify.org?format=json')
.then(results => results.json())
.then(data => console.log(data.ip));
import("https://api.ipify.org?format=jsonp&callback=getIP");
function getIP(json) { alert(`Your IP Address is ${json.ip}`) }
<script type="application/javascript">
function getIP(json) {
document.write("My public IP address is: ", json.ip);
}
</script>
<script type="application/javascript" src="https://api.ipify.org?format=jsonp&callback=getIP"></script>