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.

google-spreadsheet error: cannot read property of undefined

See original GitHub issue

hi! i am newer with sailsJs. And now i want to modify a google spreadsheet with nodeJs(using sailsJs). This is my code:

var GoogleSpreadsheet = require("google-spreadsheet");
var my_sheet = new GoogleSpreadsheet('<1Oaxk4rq2W6EhpE0sIP2ZLDcqeBIm-c7RB1Cb5Jyst44>');
/*
var creds = {
client_email: '716006945997-26pdbtn44rnop358e6qn7i8i4ucdbonv@developer.gserviceaccount.com',
private_key: ''
 }
*/
var creds = require('google-generated-creds.json');

my_sheet.useServiceAccountAuth(creds, function(err){
// getInfo returns info about the sheet and an array or "worksheet" objects
my_sheet.getInfo( function( err, sheet_info ){
  if(err)
    res.send(err);
    console.log( sheet_info.title + ' is loaded' );
    // use worksheet object if you want to stop using the # in your calls

    var sheet1 = sheet_info.worksheets[0];
    sheet1.getRows( function( err, rows ){
        rows[0].colname = 'new val';
        rows[0].save(); //async and takes a callback
        rows[0].del();  //async and takes a callback
    });
 });

 // column names are set by google and are based
 // on the header row (first row) of your sheet
my_sheet.addRow( 2, { colname: 'col value'} );

my_sheet.getRows( 2, {
    start: 100,          // start index
    num: 100,              // number of rows to pull
    orderby: 'name'  // column to order results by
 }, function(err, row_data){
    // do something...
  });
  })

But i have this error: Cannot read property ‘title’ of undefined. Please, is there anyone who can help me to fix my problem? Thanks in advance

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
omkarsk98commented, Jun 25, 2018

@Syedayesha Please share the sheet with your service account. The code like that of @jtarre will start working.

0reactions
Syedayeshacommented, Aug 2, 2017

Eventhough I am getting the same error any help how to fix this…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read property 'spreadsheets' of undefined - google ...
"Cannot read property 'spreadsheets' of undefined". I tried copy sample from google page and same error; function makeApiCall() { var ...
Read more >
TypeError: Cannot read property 'range' of undefined
An onEdit script is triggered (automatically) if edits take place in the spreadsheet. The script captures that edit (event) and uses that event-object...
Read more >
What does 'TypeError: Cannot read property '1' of undefined ...
It generally means that at the point of execution, the variable/object holding the property cannot be found by the script. It may be...
Read more >
Fixing error: cannot read property "values" from undefined
This issue usually indicates an issue with a typo in the function, or a mis-referenced spreadsheet cell. Are you sure that the values...
Read more >
Google-apps-script – TypeError: Cannot read property 'range ...
It's very likely that you are running the onformsubmit function from the script editor which don't send an event object ( e )....
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