0
Delete a gist comment
One script reply has been approved by the moderators Verified
Created by hugo697 319 days ago Viewed 9002 times
0
Submitted by hugo697 Typescript (fetch-only)
Verified 319 days ago
1
type Github = {
2
  token: string;
3
};
4
/**
5
 * Delete a gist comment
6
 *
7
 */
8
export async function main(auth: Github, gist_id: string, comment_id: string) {
9
  const url = new URL(
10
    `https://api.github.com/gists/${gist_id}/comments/${comment_id}`
11
  );
12

13
  const response = await fetch(url, {
14
    method: "DELETE",
15
    headers: {
16
      Authorization: "Bearer " + auth.token,
17
    },
18
    body: undefined,
19
  });
20
  if (!response.ok) {
21
    const text = await response.text();
22
    throw new Error(`${response.status} ${text}`);
23
  }
24
  return await response.text();
25
}
26