access ip address by js code example
Example 1: how to get ip address in javascript
fetch('https://api.ipify.org/?format=json')
.then(response => response.json())
// Returns
{
"ip": "user_ip"
}
Example 2: javascript ip address
$.getJSON('https://ipgeolocation.abstractapi.com/v1/?api_key=<your_api_key>', function(data) {
console.log(JSON.stringify(data, null, 2));
});