ip-address-retriever
v1.0.1
Published
A utility for retrieving the public IPv4 and IPv6 addresses using the ipify API.
Downloads
76
Maintainers
Readme
ip-address-retriever
A TypeScript utility for retrieving the public IPv4 and IPv6 addresses using the ipify API.
Installation
Use the package manager npm or yarn to install ip-address-retriever.
npm install ip-address-retriever
yarn add ip-address-retriever
Usage
import { IP } from 'ip-address-retriever';
// Retrieve IPv4 and IPv6 addresses
async function fetchIP(): Promise<void> {
try {
const ipv4: string = await IP.getIpv4();
const ipv6: string = await IP.getIpv6();
console.log('IPv4:', ipv4);
console.log('IPv6:', ipv6);
} catch (error) {
console.error('Error:', error);
}
}
fetchIP();
API
IP.getIpv4(): Promise
Returns a promise that resolves to the public IPv4 address of the client.
IP.getIpv6(): Promise
Returns a promise that resolves to the public IPv6 address of the client.
Credit
This package utilizes the ipify API for retrieving IP addresses