question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Node.js Quickstart example in Google Calendar API is not working with parameters

See original GitHub issue

Hi, In Google Calendar API Node.js Quickstart example, when calendar.events.list() method is called with different parameters values for timeMin and maxResults, returned result is not affected with these changes.Always returns my all events.

function listEvents(auth) {
  var calendar = google.calendar('v3');
  calendar.events.list({
    auth: auth,
    calendarId: 'primary',
    timeMin: (new Date()).toISOString(),
    maxResults: 4,
    singleEvents: true,
    orderBy: 'startTime'
  }, function(err, response) {
    if (err) {
      console.log('The API returned an error: ' + err);
      return;
    }
    var events = response.items;
    if (events.length == 0) {
      console.log('No upcoming events found.');
    } else {
      console.log('Upcoming 4 events:');
      for (var i = 0; i < events.length; i++) {
        var event = events[i];
        var start = event.start.dateTime || event.start.date;
        console.log('%s - %s', start, event.summary);
      }
    }
  });
}

But it is working in APIs Explorer.

Thanks!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
JustinBeckwithcommented, Apr 29, 2018

Greetings! The quickstart is out of date. We’re working to fix that 😃 You just need to change this:

const google = require('googleapis');

To this:

const {google} = require('googleapis');

Apologies for the trouble, and hope this helps!

1reaction
dukekscommented, Mar 6, 2018

After a long time of googling I found the solution at stackoverflow. The way you have to define the query has changed. Have a look at this thread: https://stackoverflow.com/questions/48488105/google-calendar-api-v3-doesnt-respect-timemin-timemax-parameters-in-nodejs-expr

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix Google Calendar API error - node.js - Stack Overflow
Select the application type Other, enter the name "Google Calendar API Quickstart", and click the Create button. Click OK to dismiss the resulting...
Read more >
JavaScript quickstart | Google Calendar
In the Google Cloud console, go to Menu menu > APIs & Services > Credentials. Go to Credentials. Click Create Credentials > OAuth...
Read more >
Google Auth Library: Node.js Client
For the example below, you must enable the DNS API . Choosing the correct credential type automatically. Rather than manually creating an OAuth2 ......
Read more >
Google APIs Node.js Client - googleapis documentation
Support for authorization and authentication with OAuth 2.0, API Keys and JWT tokens is included. Google APIs; Getting started. Installation; Using the client ......
Read more >
Google Calendar API with NodeJS | Step by Step - YouTube
Hello everyone,In this video, I will talk about how you can use Google Calendar API with NodeJS step by step.Step 1 - Create...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found