繁体   English   中英

谷歌日历 API 不返回所有事件

[英]Google Calendar API doesn't return all events

我在我的 React 项目中集成了 google API。 我的日历中有大约 300 个条目,但我只收到大约 180 个条目。

我的错误是什么?

保护你!

const getEvents = async () => {
    function start() {
        gapi.client
            .init({
                apiKey: "MyKey",
            })
            .then(function () {
                return gapi.client.request({
                    path: `https://www.googleapis.com/calendar/v3/calendars/"myMail"/events`,
                });
            })
            .then((response) => {
                let events = response.result.items;
                console.log(events);
                setEventObject(events);
            });
    }
    gapi.load("client", start);
};

更新这不起作用。 似乎附加参数对请求没有影响......

const getEvents = () => {
    function start() {
        gapi.client
            .init({
                apiKey: "myKey",
            })
            .then(function () {
                return gapi.client.request({
                    path: `https://www.googleapis.com/calendar/v3/calendars/"myMail"/events`,
                    maxResults: 2500,
                    showDeleted: true,
                });
            })
            .then((response) => {
                let events = response.result.items;
                console.log(events);
                setEventObject(events);
            });
    }
    gapi.load("client", start);
};

您通过请求以错误的方式传递参数。 查看谷歌 github

您需要以键值对形式传递params URL 参数。

return gapi.client.request({
    path: `https://www.googleapis.com/calendar/v3/calendars/"myMail"/events`,
    params: { maxResults: 2500, showDeleted: true }
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM