Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle Calendar API NodeJS - specify fields
    text
    copied!<p>Heyo, I'm using the <a href="https://npmjs.org/package/googleapis" rel="nofollow">google-api-nodejs-client</a> package in my NodeJS project and I'm trying to build my query for calendar events. It's working, but I can't specify the "fields" field.</p> <p>This returns five complete calendar events:</p> <pre><code>client.calendar.events.list({ calendarId: gcal_id, maxResults: 5 }) .withAuthClient(authClient) .execute(function(err, calendar) { if (err) console.log(err); else console.log(calendar); }); </code></pre> <p>But this returns nothing:</p> <pre><code>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); }); </code></pre> <p>I've also tried:</p> <pre><code>fields: { items: "end,start,status,summary" } </code></pre> <p>Based on the Google Calendar V3 API, I should be able to make a query like this: <a href="https://www.googleapis.com/calendar/v3/calendars/gcal_id.google.com/events?maxResults=5&amp;fields=items(end%2Cstart%2Cstatus%2Csummary)&amp;key=" rel="nofollow">https://www.googleapis.com/calendar/v3/calendars/gcal_id.google.com/events?maxResults=5&amp;fields=items(end%2Cstart%2Cstatus%2Csummary)&amp;key=</a>{YOUR_API_KEY}</p> <p>I'm not sure how to specify the "fields=items(end%2Cstart%2Cstatus%2Csummary)" portion of the URL, but I've tested it in Google's API Explorer and it works, so I know I'm doing something wrong in the JavaScript.</p> <p>Any help would be much appreciated. For now I think I'll just clean up the response I get from the first code snippet.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload