UNPKG

location-from-ip

Version:

`location-from-ip` gives IP Geolocation information for every IPv4 or IPv6 address

14 lines 352 B
function ipToGeolocation(ip) { return new Promise(function (resolve) { fetch(`https://api.ipapi.is/?q=${ip}`) .then(res => res.json()) .then(function (parsed) { try { if (parsed && parsed.location) { resolve(parsed.location); } } catch (err) { } resolve(null); }); }); }