I integrated the google API in my react project. I have about 300 Entries in my calendar but I only receive about 180 entries.
What is my Mistake?
Tank you!
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);
};
UPDATE This doesn't work. It seems like the additional parameters has no impact of the request...
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);
};
Your passing your parameters the wrong way through the request. Checkout the google github
You need to pass the params URL params in key-value pair form.
return gapi.client.request({
path: `https://www.googleapis.com/calendar/v3/calendars/"myMail"/events`,
params: { maxResults: 2500, showDeleted: true }
});