Created
May 6, 2017 14:30
-
-
Save bmoren/55b9a1967351062e8f2915e65be65801 to your computer and use it in GitHub Desktop.
get a users ip using an api
This file contains 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 userIP | |
function setup() { | |
createCanvas(windowWidth,windowHeight) | |
//go to https://www.ipify.org/ for more information on the api in use here | |
loadJSON('https://api.ipify.org?format=json',function(returnedData){ | |
userIP = returnedData.ip //put it in the global scope. | |
console.log(userIP); | |
}) | |
} | |
function draw() { | |
if(userIP){ //detect if there is a user ip or if something went wrong. | |
text(userIP,100,100) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment