Skip to content

Instantly share code, notes, and snippets.

@bmoren
Created May 6, 2017 14:30
Show Gist options
  • Save bmoren/55b9a1967351062e8f2915e65be65801 to your computer and use it in GitHub Desktop.
Save bmoren/55b9a1967351062e8f2915e65be65801 to your computer and use it in GitHub Desktop.
get a users ip using an api
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