2
votes

I am using Google Sheets API with NodeJS and trying out the simplest demo from https://developers.google.com/sheets/api/quickstart/nodejs

I am getting a runtime error "google.sheets is not a function". When I am inspecting, I got the debug screenshot below,

enter image description here

The google variable is from var google = require("googleapis");, which seems to load well(has a bunch of content inside). Of its properties there does not seem to have a "sheets" property, thus the executing result will say it is not a function.

No one is asking a similar question online. Did I miss a very obvious step of setting up?

1
I thought that library for using sheets api might not be installed correctly in your environment. In my experiences, for the same situation, the problem was solved by re-installing googleapis. Although I don't know whether this is directly solved your problem, can you re-install googleapis? Using this sample script (var google = require('googleapis'); var sheets = google.sheets('v4');), you can confirm whether the sheets api can be used. - Tanaike

1 Answers

1
votes

Change the import to:

var {google} = require("googleapis");