google-spreadsheet error: cannot read property of undefined
See original GitHub issuehi! 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:
- Created 8 years ago
- Comments:10 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Syedayesha Please share the sheet with your service account. The code like that of @jtarre will start working.
Eventhough I am getting the same error any help how to fix this…