js get current ip address code example
Example 1: how to get ip address in javascript
fetch('https://api.ipify.org/?format=json')
.then(response => response.json())
{
"ip": "user_ip"
}
Example 2: how to get user ip address in javascript
<script>
function getIP(json) {
alert("My public IP address is: " + json.ip);
}
</script>
<script src="https://api.ipify.org?format=jsonp&callback=getIP"></script>
<script type="application/javascript" src="https://api.ipify.org?format=jsonp&callback=getIP"> </script>