Edits history of script submission #12184 for ' Retrieve the IP address of your visitors or users without the need for an account or API key in Greip (greip)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Greip = {
      apiKey: string;
    };
    /**
     * Retrieve the IP address of your visitors or users without the need for an account or API key in Greip
     * This method allows you to retrieve the IP address of your visitors or users without the need for an account or API key in Greip.
    
    It’s a quick and easy way to access IP information, making it ideal for basic integrations or when you need to capture user IPs with minimal setup.
     */
    export async function main(auth: Greip) {
      const url = new URL(`https://greipapi.com/ip`);
    
      const response = await fetch(url, {
        method: "GET",
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.text();
    }
    

    Submitted by hugo697 428 days ago