Skip to content

Instantly share code, notes, and snippets.

@vbguard
Forked from luxplanjay/get-ip.js
Created July 11, 2018 12:52
Show Gist options
  • Save vbguard/26df386888ec89d6915b8472e6298a5e to your computer and use it in GitHub Desktop.
Save vbguard/26df386888ec89d6915b8472e6298a5e to your computer and use it in GitHub Desktop.
fetch('https://api.ipify.org?format=json')
.then(response => {
if (response.ok) return response.json();
throw Error('Error while fetching' + response.statusText);
})
.then(data => console.log(data))
.catch(err => console.log(err));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment