micro-geoip-lite
🌍 An extremely lite geoip decoder utilizing the micro-geoip-lite microservice to geo decode the IP info via an https request - the microservice utilizes MaxMind's IP info dataset.
Installation
- Run
yarn add micro-geoip-lite
,npm i micro-geoip-lite
Usage
-
params:
- ip?: string - optional, defaults to client's IP
- options?:
{ serviceUrl: string }
- optional, called instead of the default provider URL. You can also provide this via an env varREACT_APP_SERVICE_URL_GEOIP
orSERVICE_URL_GEOIP
-
returns:
ip: string // if ip param was not provided, this defaults to request.iprange: number numbercountry: stringregion: stringeu: string // '0' or '1'timezone: stringcity: stringll: number numbermetro: numberarea: number// error: 'Error text', // only exists if an error happened -
example - fetch own ip info:
;const result = await ;ip: '207.97.227.239' // if ip param was not provided, this defaults to request.iprange: 3479298048 3479300095country: 'US'region: 'TX'eu: '0'timezone: 'America/Chicago'city: 'San Antonio'll: 294969 -984032metro: 641area: 1000// error: 'Error text', // only exists if an error happened -
example - fetch specific ip info:
;const result = await ;