0

Preview active event details

by
Published Nov 16, 2023

Previews an event's configuration as if it was active. Inherited fields from the waiting room will be displayed with their current values.

Script cloudflare Verified

The script

Submitted by hugo697 Typescript (fetch-only)
Verified 403 days ago
1
type Cloudflare = {
2
  token: string;
3
  email: string;
4
  key: string;
5
};
6
/**
7
 * Preview active event details
8
 * Previews an event's configuration as if it was active. Inherited fields from the waiting room will be displayed with their current values.
9
 */
10
export async function main(
11
  auth: Cloudflare,
12
  event_id: string,
13
  waiting_room_id: string,
14
  zone_identifier: string
15
) {
16
  const url = new URL(
17
    `https://api.cloudflare.com/client/v4/zones/${zone_identifier}/waiting_rooms/${waiting_room_id}/events/${event_id}/details`
18
  );
19

20
  const response = await fetch(url, {
21
    method: "GET",
22
    headers: {
23
      "X-AUTH-EMAIL": auth.email,
24
      "X-AUTH-KEY": auth.key,
25
      Authorization: "Bearer " + auth.token,
26
    },
27
    body: undefined,
28
  });
29
  if (!response.ok) {
30
    const text = await response.text();
31
    throw new Error(`${response.status} ${text}`);
32
  }
33
  return await response.json();
34
}
35