Create reaction for a team discussion comment (Legacy)

**Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API.

Script github Verified

by hugo697 ยท 10/25/2023

The script

Submitted by hugo697 Typescript (fetch-only)
Verified 367 days ago
1
type Github = {
2
  token: string;
3
};
4
/**
5
 * Create reaction for a team discussion comment (Legacy)
6
 * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API.
7
 */
8
export async function main(
9
  auth: Github,
10
  team_id: string,
11
  discussion_number: string,
12
  comment_number: string,
13
  body: {
14
    content:
15
      | "+1"
16
      | "-1"
17
      | "laugh"
18
      | "confused"
19
      | "heart"
20
      | "hooray"
21
      | "rocket"
22
      | "eyes";
23
    [k: string]: unknown;
24
  }
25
) {
26
  const url = new URL(
27
    `https://api.github.com/teams/${team_id}/discussions/${discussion_number}/comments/${comment_number}/reactions`
28
  );
29

30
  const response = await fetch(url, {
31
    method: "POST",
32
    headers: {
33
      "Content-Type": "application/json",
34
      Authorization: "Bearer " + auth.token,
35
    },
36
    body: JSON.stringify(body),
37
  });
38
  if (!response.ok) {
39
    const text = await response.text();
40
    throw new Error(`${response.status} ${text}`);
41
  }
42
  return await response.json();
43
}
44