1
Create Quick Event
One script reply has been approved by the moderators Verified
Created by rossmccrann 663 days ago Viewed 7268 times
0
Submitted by rossmccrann Deno
Verified 663 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