Edits history of script submission #16613 for ' Get Web Hooks (kustomer)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Kustomer = {
      apiKey: string;
    };
    /**
     * Get Web Hooks
     * Fetches web hooks.
    
    A web hook allows you to pass data into Kustomer by posting to a designated endpoint.
    
    The webhook contains a URL to post data to and a workflow event to process the incoming data.
    
    This endpoint will return a maximum of 10 pages with 99 entries.
     */
    export async function main(auth: Kustomer) {
      const url = new URL(`https://api.kustomerapp.com/v1/hooks/web`);
    
      const response = await fetch(url, {
        method: "GET",
        headers: {
          Authorization: "Bearer " + auth.apiKey,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 235 days ago