UNPKG

ip-to-hosting

Version:

This package allows you to check whether an IP address belongs to a hosting provider or not. In case the IP address can be successfully linked to a hosting provider (datacenter), this module will return the meta information for the hosting provider.

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