Edits history of script submission #14082 for ' List entries (attio)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Attio = {
      token: string;
    };
    /**
     * List entries
     * Lists entries in a given list, with the option to filter and sort results.
    
    Required scopes: `list_entry:read`, `list_configuration:read`.
     */
    export async function main(
      auth: Attio,
      list: string,
      body: {
        filter?: {};
        sorts?:
          | { direction: "asc" | "desc"; attribute: string; field?: string }
          | { direction: "asc" | "desc"; path: string[][]; field?: string }[];
        limit?: number;
        offset?: number;
      },
    ) {
      const url = new URL(`https://api.attio.com/v2/lists/${list}/entries/query`);
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Bearer " + auth.token,
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 235 days ago