1

嘿嘿,我在我的 NodeJS 项目中使用google-api-nodejs-client包,我正在尝试为日历事件构建查询。它正在工作,但我无法指定“字段”字段。

这将返回五个完整的日历事件:

client.calendar.events.list({
    calendarId: gcal_id,
    maxResults: 5
})
.withAuthClient(authClient)
.execute(function(err, calendar) {
    if (err)
        console.log(err);
    else
        console.log(calendar);
});

但这没有返回:

client.calendar.events.list({
    calendarId: gcal_id,
    maxResults: 5,
    fields: {
        items: ["end","start","status","summary"]
    }
})
.withAuthClient(authClient)
.execute(function(err, calendar) {
    if (err)
        console.log(err);
    else
        console.log(calendar);
});

我也试过:

fields: {
    items: "end,start,status,summary"
}

基于 Google Calendar V3 API,我应该能够进行如下查询: https ://www.googleapis.com/calendar/v3/calendars/gcal_id.google.com/events?maxResults=5&fields=items(end %2Cstart%2Cstatus%2Csummary)&key= {YOUR_API_KEY}

我不确定如何指定 URL 的“fields=items(end%2Cstart%2Cstatus%2Csummary)”部分,但我已经在 Google 的 API Explorer 中对其进行了测试并且它可以工作,所以我知道我正在做某事JavaScript 中的错误。

任何帮助将非常感激。现在我想我会清理从第一个代码片段中得到的响应。

4

1 回答 1

5

嗯,我想通了。它应该是一个字符串。

fields: "items(end,start,status,summary)"
于 2013-10-18T09:45:12.553 回答