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.

addWorksheet method fails: this.isAuthActive is not a function

See original GitHub issue

Running the following code on Node.js v10.16.0:

const Gss = require('google-spreadsheet');
const { promisify } = require('util');
const creds = require('./client_secret.json');

const main = async () => {
  const sheetId = '<sheet id>';
  const doc = new Gss(sheetId);
  await promisify(doc.useServiceAccountAuth)(creds);

  const sheet = await promisify(doc.addWorksheet)({
    title: 'test',
  });
};

main();

fails with

(node:13279) UnhandledPromiseRejectionWarning: TypeError: this.isAuthActive is not a function
    at GoogleSpreadsheet.addWorksheet (/home/niklash/standup-query-bot/bot/node_modules/google-spreadsheet/index.js:225:15)

google-spreadsheet version is: 2.0.7

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:7

github_iconTop GitHub Comments

1reaction
baruchirocommented, Nov 29, 2019

I think: Before:

promisify(doc.addWorksheet)(options)

After:

promisify(doc.addWorksheet).call(doc, options)
1reaction
xhalo32commented, Oct 22, 2019

@amrshakya The issue was that the promisified method did not have this bound which the function requires, i.e. I was trying to use the method like a static class method. Thus when I bound the doc as this using .call it worked like an ordinary non-static method call. I suppose doc.useServiceAccountAuth does not use this and that’s why it worked without the bound context. Classic javascript

Read more comments on GitHub >

github_iconTop Results From Across the Web

workbook.addWorkSheet is not a function · Issue #472 - GitHub
I tried making a small demo file that would make two calls to the method that does the new ExcelJS.Workbook() - and it...
Read more >
"Error in addWorksheet(wb, "sheet1") : First argument must be ...
The code you have shared doesn't throw any error in my case. The error message you have shared indicates that the workbook wb...
Read more >
addWorksheet: Add a worksheet to a workbook in openxlsx
wb. A Workbook object to attach the new worksheet ; sheetName. A name for the new worksheet ; gridLines. A logical. If FALSE...
Read more >
Excel workbook is not activated when you run a macro - Office
Provides a workaround for an issue that prevents the Workbook.Activate method from working as expected if the ScreenUpdating property is set ...
Read more >
Excel.ActiveWorkBook.WorkSheets is not a function
This is the code the error is being thrown on. function ReadRow(rownum, columnstart, filename, sheetname, columnend) {. var filepath = "C:/ ...
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