Skip to content
This repository has been archived by the owner on Jan 27, 2022. It is now read-only.

Cannot read property 'entry' of undefined when loading sheet by name #34

Open
ryan-williams opened this issue Oct 4, 2015 · 2 comments

Comments

@ryan-williams
Copy link

$ cat gsheet.js
#!/usr/bin/env node

var GoogleSpreadsheets = require("google-spreadsheets");

var key = process.argv[2];
var range = process.argv[3];

GoogleSpreadsheets.cells(
      {
        key: key,
        worksheet: "Sheet1",
        range: range
      },
      function(err, cells) {
        console.log("cells:", err, cells);
      }
);
$ gsheet.js 1Bb-SLy4E-alUUSJ68Qb5nNmZG6HsPbG2j6Ye_QZO77Y A1:A3
/Users/ryan/node_modules/google-spreadsheets/lib/spreadsheets.js:284
    if(typeof data.entry !== "undefined" && data.entry !== null) {
                  ^

TypeError: Cannot read property 'entry' of undefined
    at /Users/ryan/node_modules/google-spreadsheets/lib/spreadsheets.js:284:19
    at Request.reqCallback [as _callback] (/Users/ryan/node_modules/google-spreadsheets/lib/spreadsheets.js:70:5)
    at Request.self.callback (/Users/ryan/node_modules/google-spreadsheets/node_modules/request/request.js:198:22)
    at emitTwo (events.js:87:13)
    at Request.emit (events.js:172:7)
    at Request.<anonymous> (/Users/ryan/node_modules/google-spreadsheets/node_modules/request/request.js:1063:14)
    at emitOne (events.js:82:20)
    at Request.emit (events.js:169:7)
    at IncomingMessage.<anonymous> (/Users/ryan/node_modules/google-spreadsheets/node_modules/request/request.js:1009:12)
    at emitNone (events.js:72:20)

Trying to load range A1:A3 from this sheet.

@samcday
Copy link
Owner

samcday commented Oct 7, 2015

Well, the settings for the spreadsheet were all wrong - I updated it to Publish to the web and also make sure the sharing settings were configured to allow anyone on the web to view (as per the README). However, now the provided script is failing with a 400 Bad Request error. Not sure what's going on there.

@ryan-williams
Copy link
Author

Thanks @samcday, sounds like there's a few things in play here:

  1. I had it set to "Anyone with the link can edit", but you've pointed out that that was supposed to be "Anyone on the internet can find and edit", if I wanted to use an anonymous request. That makes sense, sorry for misreading the README.
  2. Now my example above returns Error: HTTP error 400: Bad Request, as you mentioned.
  3. The original error message, when the sheet's permissions are not set correctly, is confusing / does not indicate the problem.

It seems like 2. and 3. could each warrant filing an issue; shall I convert this one to address 3. (the error message) and file a new issue for 2.?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants