1

Create Quick Event

by
Published Jul 26, 2022
Script gcal Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 7 days ago
1
//native
2

3
type Gcal = {
4
  token: string;
5
};
6
export async function main(
7
  gcal_auth: Gcal,
8
  calendarId: string,
9
  eventText: string,
10
) {
11
  const sendUpdates = "all";
12

13
  const QUICK_EVENT_URL = `https://www.googleapis.com/calendar/v3/calendars/${calendarId}/events/quickAdd/?text=${eventText}&sendUpdates=${sendUpdates}`;
14

15
  const token = gcal_auth["token"];
16

17
  const response = await fetch(QUICK_EVENT_URL, {
18
    method: "POST",
19
    headers: {
20
      Authorization: "Bearer " + token,
21
      "Content-Type": "application/json",
22
    },
23
  });
24

25
  const result = await response.json();
26

27
  return result;
28
}
29

Other submissions
  • Submitted by rossmccrann Deno
    Created 399 days ago
    1
    type Gcal = {
    2
      token: string;
    3
    };
    4
    export async function main(
    5
      gcal_auth: Gcal,
    6
      calendarId: string,
    7
      eventText: string,
    8
    ) {
    9
      const sendUpdates = "all";
    10
    
    
    11
      const QUICK_EVENT_URL = `https://www.googleapis.com/calendar/v3/calendars/${calendarId}/events/quickAdd/?text=${eventText}&sendUpdates=${sendUpdates}`;
    12
    
    
    13
      const token = gcal_auth["token"];
    14
    
    
    15
      const response = await fetch(QUICK_EVENT_URL, {
    16
        method: "POST",
    17
        headers: {
    18
          Authorization: "Bearer " + token,
    19
          "Content-Type": "application/json",
    20
        },
    21
      });
    22
    
    
    23
      const result = await response.json();
    24
    
    
    25
      return result;
    26
    }
    27