从无服务器函数进行 API 调用。在本地,调用返回正确,在生产中我得到重复的结果。请注意项目数组中第一个和最后一个项目的 ID。
{kind: "calendar#events", etag: ""p33gan841gmfv00g"", summary: "DFW Nets",…}
accessRole: "owner"
defaultReminders: []
etag: "\"p33gan841gmfv00g\""
items: [,…]
0: {kind: "calendar#event", etag: ""3238943100952000"", id: "7e5jjq2eos56vn0dsrcr3bgbod_20210428T233000Z",…}
1: {kind: "calendar#event", etag: ""3238991623418000"", id: "0b02a4ik62avudben41ec3bmfs_20210429T033000Z",…}
2: {kind: "calendar#event", etag: ""3238946501106000"", id: "7p37af8hkuli5htepdmu5t6qf4_20210429T170000Z",…}
3: {kind: "calendar#event", etag: ""3238943100952000"", id: "7e5jjq2eos56vn0dsrcr3bgbod_20210429T233000Z",…}
kind: "calendar#events"
summary: "DFW Nets"
timeZone: "America/Chicago"
updated: "2021-04-27T18:20:12.780Z"
无服务器函数中的代码
calendar.events.list({
auth: oAuth2Client,
calendarId: "[email protected]",
singleEvents: true,
showDeleted: false,
timeMin: today.toISOString(),
maxResults: 10,
timeMax: tomorrow.toISOString(),
orderBy: "startTime"
},
(error, response) => {
if (error) {
console.log(error);
return;
}
callback(null, {
headers: {
"Access-Control-Allow-Origin": "*"
},
statusCode: 200,
body: JSON.stringify(response.data)
});
}
); };
补充一点,在这个生产环境中实际上也缺少结果。 API 浏览器也返回与开发相同的正确结果。问题出在 netlify 托管的捆绑代码中
注意:timeMin 和 timeMax 的格式都是正确的。 如果我不包括 timeMax - 结果似乎显示正确?
这些是重复发生的事件 - 当您调用
singleEvents
时尝试设置
list
属性
谢谢!这解决了我的问题,并且我得到了对已修改的同一事件的多个响应。