首页 > 解决方案 > 在节点 js 中获取谷歌日历事件 ID

问题描述

我正在尝试从 node.js 中的谷歌日历中删除一个事件,这需要一个 ID 才能删除该事件。

我没有找到任何方法在谷歌日历文档中获取此 ID。有没有办法使用特定方法获取事件 ID?

function deleteEvent(agent) {
console.log('delete event function');


    //Check the availability of the time slot and set up an appointment if the time slot is available on the calendar
    return getEventId().then(() => {
      agent.add(`Got it. the event deleted`);
    }).catch(() => {
      agent.add(`Sorry`);
    });

  }
  function getEventId(){


  console.log("get event id function");

  eventId='******';
  return deleteCalendarEvent().then(()=>{
    console.log('success');
  }).catch(()=>{
    console.log('fail');
  });



  }// getEmailsForDepartment

  function deleteCalendarEvent(){
    return new Promise((resolve, reject) => {
      calendar.events.delete({  
        auth: serviceAccountAuth,
        calendarId: calendarId,

        eventId:eventId
      }, (err, event) => {
        err ? reject(err) : resolve(event);
      });
    });
  }


标签: javascriptnode.jsgoogle-apigoogle-calendar-apidialogflow-es

解决方案


您可以使用Events: list列出所有事件。然后按标题、日期或类似内容进行过滤以获取所需事件的 ID。请参阅 https://developers.google.com/calendar/v3/reference/events/list

在浏览器 UI 中,如果单击故障排除信息,您会看到 eid。


推荐阅读