Update an existing project card
One script reply has been approved by the moderators Verified
Created by hugo697 817 days ago
Submitted by hugo697 Typescript (fetch-only)
Verified 256 days ago
1
type Github = {
2
  token: string;
3
};
4
/**
5
 * Update an existing project card
6
 *
7
 */
8
export async function main(
9
  auth: Github,
10
  card_id: string,
11
  body: { archived?: boolean; note?: string; [k: string]: unknown }
12
) {
13
  const url = new URL(
14
    `https://api.github.com/projects/columns/cards/${card_id}`
15
  );
16

17
  const response = await fetch(url, {
18
    method: "PATCH",
19
    headers: {
20
      "Content-Type": "application/json",
21
      Authorization: "Bearer " + auth.token,
22
    },
23
    body: JSON.stringify(body),
24
  });
25
  if (!response.ok) {
26
    const text = await response.text();
27
    throw new Error(`${response.status} ${text}`);
28
  }
29
  return await response.json();
30
}
31