@dumorando/yourip
v1.0.0
Published
Package to easily get your IP.
Downloads
1
Readme
YourIP
This is a simple NodeJS library to get the IP of your computer. Synchronous example
const YourIP = require("@dumorando/yourip");
const ip = new YourIP();
console.log(ip.GetIPSync()); //logs your IP into console.
Asynchronous example
(async () => {
const YourIP = require("@dumorando/yourip");
const ip = new YourIP();
console.log(await ip.GetIP()); //logs your IP into console.
})();
The default API YourIP uses to get your IP is https://api.ipify.org/
. You can specify wich endpoint you want to use though. It must return just plain text and not a JSON response.
const ip = new YourIP("https://ip.dumorando.com"); //if you want ipv6
You can also get the current endpoint.
const ip = new YourIP("https://ip.dumorando.com");
console.log(ip.endpoint); // https://ip.dumorando.com