Edits history of script submission #14104 for ' Update an object (attio)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Attio = {
      token: string;
    };
    /**
     * Update an object
     * Updates a single object. The object to be updated is identified by its `object_id`.
    
    Required scopes: `object_configuration:read-write`.
     */
    export async function main(
      auth: Attio,
      object: string,
      body: {
        data: { api_slug?: string; singular_noun?: string; plural_noun?: string };
      },
    ) {
      const url = new URL(`https://api.attio.com/v2/objects/${object}`);
    
      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