Answers for "js get server ip"

3

how to get ip address in javascript

fetch('https://api.ipify.org/?format=json')
  .then(response => response.json())
// Returns 
{
 "ip": "user_ip"
}
Posted by: Guest on April-24-2021
0

get ip address js

function getIPFromAmazon() {
	fetch("https://checkip.amazonaws.com/").then(res => res.text()).then(data => console.log(data))
}

getIPFromAmazon();
Posted by: Guest on January-22-2022
0

Get IP Address with js

<!DOCTYPE html>
<html>
 
<head>
    <title>Getting Clients IP</title>
     
    <style>
    h1 {
        color: green;
    }
    </style>
    <script src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js">
    </script>
     
    <script>
     
    // Add "https://ipinfo.io" statement
    // this will communicate with the ipify servers
    // in order to retrieve the IP address
    $.get("https://ipinfo.io", function(response) {
            alert(response.ip);
        }, "json")
         
        // "json" shows that data will be fetched in json format
    </script>
</head>
 
<body>
    <center>
        <h1>GeeksforGeeks</h1>
        <h3>Getting Client IP address</h3>
    </center>
</body>
 
</html>
Posted by: Guest on February-21-2022

Code answers related to "Javascript"

Browse Popular Code Answers by Language