UNPKG
get-public-ipv4
Version:
latest (1.0.2)
1.0.2
1.0.1
1.0.0
Fetches the public IP address using the ipify.org API
get-public-ipv4
/
test.js
11 lines
(9 loc)
•
235 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
const
getPublicIP =
require
(
"get-public-ipv4"
); (
async
() => {
try
{
const
ip =
await
getPublicIP
();
console
.
log
(
"Public IP:"
, ip); }
catch
(err) {
console
.
error
(
"Failed to fetch public IP:"
, err); } })();