1. Make a variable and set value to "https://api.ipify.org/"

var url = "https://api.ipify.org"

2. Make another variable and start http request.



// Creating request
var nice = new XMLHttpRequest();

nice.open("GET", url);
// Getting response
nice.onreadystatechange =

function() {

  if (nice.readyState === 4) {// Logging the response (IP) in console

    console.log("Your public IP is: "+nice.responseText);

  }

}
// Sending the request
nice.send();

3. And yeah - run it. You should be able to see your public IP!