List Invitations

Lists all invitations associated with my user.

Script cloudflare Verified

by hugo697 ยท 11/16/2023

The script

Submitted by hugo697 Typescript (fetch-only)
Verified 383 days ago
1
type Cloudflare = {
2
  token: string;
3
  email: string;
4
  key: string;
5
};
6
/**
7
 * List Invitations
8
 * Lists all invitations associated with my user.
9
 */
10
export async function main(auth: Cloudflare) {
11
  const url = new URL(`https://api.cloudflare.com/client/v4/user/invites`);
12

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