Google 日历 API 不 return 所有事件
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);
};
您通过请求以错误的方式传递参数。 Checkout the google github
您需要以键值对形式传递 params
URL 参数。
return gapi.client.request({
path: `https://www.googleapis.com/calendar/v3/calendars/"myMail"/events`,
params: { maxResults: 2500, showDeleted: true }
});
我在我的 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);
};
您通过请求以错误的方式传递参数。 Checkout the google github
您需要以键值对形式传递 params
URL 参数。
return gapi.client.request({
path: `https://www.googleapis.com/calendar/v3/calendars/"myMail"/events`,
params: { maxResults: 2500, showDeleted: true }
});