Edits history of script submission #14067 for ' Get a comment (attio)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Attio = {
      token: string;
    };
    /**
     * Get a comment
     * Get a single comment by ID.
    
    To view comments on records, you will need the `object_configuration:read` and `record_permission:read` scopes.
    
    To view comments on list entries, you will need the `list_configuration:read` and `list_entry:read` scopes.
    
    Required scopes: `comment:read`.
     */
    export async function main(auth: Attio, comment_id: string) {
      const url = new URL(`https://api.attio.com/v2/comments/${comment_id}`);
    
      const response = await fetch(url, {
        method: "GET",
        headers: {
          Authorization: "Bearer " + auth.token,
        },
        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