Get team membership for a user (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 366 days ago
1
type Github = {
2
  token: string;
3
};
4
/**
5
 * Get team membership for a user (Legacy)
6
 * **Deprecation Notice:** This endpoint route is deprecated and will be removed from the Teams API.
7
 */
8
export async function main(auth: Github, team_id: string, username: string) {
9
  const url = new URL(
10
    `https://api.github.com/teams/${team_id}/memberships/${username}`
11
  );
12

13
  const response = await fetch(url, {
14
    method: "GET",
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.json();
25
}
26