Created
December 19, 2016 23:51
-
-
Save pganti/3e6fe786e345628e542d351bbd91ff29 to your computer and use it in GitHub Desktop.
xhr ip
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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