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.

calendar Quickstart.js should write token using fs.writeFileSync, not fs.writeFile.

See original GitHub issue

fs.writeFile does not wait for the writing to complete, and I would end up with an empty /.credentials/calednar-nodejs-quickstart.json file. This of course would crash the app on subsequent starts as it either expects the file to NOT EXIST, or it to exist and have some data.

My fix was to replace fs.writeFile(TOKEN_PATH, JSON.stringify(token)); with fs.writeFileSync(TOKEN_PATH, JSON.stringify(token), 'utf8');, thus insuring that the program actually writes the file.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
JustinBeckwithcommented, Mar 5, 2018

Ah! So yes, the tutorial is out of date. However, the readFile part looks right. We’re in the process of updating and testing out samples, so apologies for the confusion!

0reactions
cepm-natecommented, Mar 5, 2018

The tutorial at https://developers.google.com/google-apps/calendar/quickstart/nodejs still seems to reference fs.writeFile instead of fs.writeFileSync. Was it updated somewhere else?

And if not changed already, the const google = require('googleapis'); should be const {google} = require('googleapis'); (same as #999 )

Read more comments on GitHub >

github_iconTop Results From Across the Web

NodeJS, Google Calendar API integration not authenticated ...
One of my problems was that when you, use Googles quickstart for NodeJS to connect to the Calendar API, that code will ask...
Read more >
sheets quickstart.js needs updating to reflect the es6 ... - GitHub
Hi, quickstart.js ( taken from https://developers.google.com/sheets/api/quickstart/nodejs ) currently fails when trying to reference ...
Read more >
Node.js quickstart | Google Calendar
Quickstarts explain how to set up and run an app that calls a Google Workspace API. Google Workspace quickstarts use the API client...
Read more >
How to integrate Google Calendar in Node.js ? - GeeksforGeeks
This article covers the integration of Google Calendar API in the NodeJS application and creating new events with service account ...
Read more >
Node.js v19.3.0 Documentation
This will print to the file and will not invoke AsyncHook recursively because it is synchronous. import { writeFileSync } from 'node:fs'; import...
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