Class IssueResource

Represents a GitHub issue resource with chainable async methods.

Implements PromiseLike<GitHubIssue> so it can be awaited directly to fetch the issue info, while also exposing sub-resource methods.

// Await directly to get issue info
const issue = await gh.repo('octocat', 'Hello-World').issue(1);

// Get comments on an issue
const comments = await gh.repo('octocat', 'Hello-World').issue(1).comments();

Implements

Methods

  • Adds a comment to this issue.

    POST /repos/{owner}/{repo}/issues/{issue_number}/comments

    Parameters

    • body: string

      The comment text

    • Optionalsignal: AbortSignal

      Optional AbortSignal to cancel the request

    Returns Promise<GitHubIssueComment>

    The created comment

    If the issue is not found or access is denied

    const comment = await gh.repo('octocat', 'Hello-World').issue(1).addComment('Thanks for the report!');
    
  • Updates this issue.

    PATCH /repos/{owner}/{repo}/issues/{issue_number}

    Parameters

    • data: UpdateIssueData

      Fields to update: title, body, state, state_reason, assignees, labels, milestone

    • Optionalsignal: AbortSignal

      Optional AbortSignal to cancel the request

    Returns Promise<GitHubIssue>

    The updated issue

    If the issue is not found or access is denied

    // Close an issue
    await gh.repo('octocat', 'Hello-World').issue(1).update({ state: 'closed', state_reason: 'completed' });

    // Rename and reassign
    await gh.repo('octocat', 'Hello-World').issue(1).update({ title: 'New title', assignees: ['octocat'] });