Skip to content

Instantly share code, notes, and snippets.

@pganti
Created December 19, 2016 23:51
Show Gist options
  • Save pganti/3e6fe786e345628e542d351bbd91ff29 to your computer and use it in GitHub Desktop.
Save pganti/3e6fe786e345628e542d351bbd91ff29 to your computer and use it in GitHub Desktop.
xhr ip
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
console.log(JSON.parse(xhttp.responseText).ip);
}
};
xhttp.open("GET", "https://api.ipify.org?format=json", true);
xhttp.send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment