Edits history of script submission #22436 for ' Get IP address insights from IPinfo - geolocation, privacy detection, company and more (ipinfo)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    type Ipinfo = {
        token: string
    }
    
    export async function main(ipinfo?: Ipinfo, ip?:string) {
        /**
         * Makes an API call to IPinfo to get IP address geolocation data and other IP data.
         * @param {string} token - Your IPinfo.io access token. This param is optional.
         * @param {string} ip - The IP address to lookup. This param is optional if you want to lookup your current IP.
         * @returns {object} - An object with the status and the payload.
         */
        const ipAddressInformation = await fetch(`https://ipinfo.io${ip ? '/' + ip : '' }/json?token=${ipinfo?.token || ""}`)
    
        return {
            status: ipAddressInformation.status,
            payload: await ipAddressInformation.json(),
        };
    }

    Submitted by hugo989 6 days ago