0

Get Issue

by
Published today

Get an issue (or pull request) by number, including its assignees, labels and state.

Script github Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 1 hour ago
1
//native
2

3
/**
4
 * Get Issue
5
 * Get an issue (or pull request) by number, including its assignees, labels and state.
6
 */
7
export async function main(
8
  auth: RT.Github,
9
  owner: string,
10
  repo: string,
11
  issue_number: number
12
) {
13
  const response = await fetch(
14
    `https://api.github.com/repos/${owner}/${repo}/issues/${issue_number}`,
15
    {
16
      headers: {
17
        Authorization: `Bearer ${auth.token}`,
18
        Accept: "application/vnd.github+json",
19
        "X-GitHub-Api-Version": "2022-11-28",
20
      },
21
    }
22
  )
23

24
  if (!response.ok) {
25
    throw new Error(`${response.status} ${await response.text()}`)
26
  }
27

28
  return await response.json()
29
}
30