1.0.0 • Published 1 year ago

@dumorando/yourip v1.0.0

Weekly downloads
-
License
Unlicense
Repository
-
Last release
1 year ago

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
1.0.0

1 year ago