Edits history of script submission #14094 for ' Update a list (attio)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Attio = {
      token: string;
    };
    /**
     * Update a list
     * Updates an existing list.
     */
    export async function main(
      auth: Attio,
      list: string,
      body: {
        data: {
          name?: string;
          api_slug?: string;
          workspace_access?: "full-access" | "read-and-write" | "read-only";
          workspace_member_access?: {
            workspace_member_id: string;
            level: "full-access" | "read-and-write" | "read-only";
          }[];
        };
      },
    ) {
      const url = new URL(`https://api.attio.com/v2/lists/${list}`);
    
      const response = await fetch(url, {
        method: "PATCH",
        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