samcday / node-google-spreadsheets

Google Spreadsheet Data API for node.js & the browser
The Unlicense
185 stars 57 forks source link

Does this still work? #18

Closed konsumer closed 10 years ago

konsumer commented 10 years ago

I have a test spreadsheet here. It's set to public link view shared.

when I run this simple code:

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

GoogleSpreadsheets({
    key: '15XaE_P3WS_1fNahoJtrZfXKV3E2LPeGdoY2syspdm9M'
}, function(err, spreadsheet) {
    if (err) {
        console.log(err);
        process.exit(1);
        return;
    }

    spreadsheet.worksheets[0].cells({
        range: "A2:C"
    }, function(err, cells) {
        if (err) {
            console.log(err);
            process.exit(1);
            return;
        }
        console.log(cells);
    });
});

I get this error:

TypeError: Cannot read property 'title' of undefined
    at new Spreadsheet (/Users/konsumer/Desktop/test/node_modules/google-spreadsheets/lib/spreadsheets.js:165:19)
    at /Users/konsumer/Desktop/test/node_modules/google-spreadsheets/lib/spreadsheets.js:73:12
    at Request._callback (/Users/konsumer/Desktop/test/node_modules/google-spreadsheets/lib/spreadsheets.js:56:3)
    at Request.self.callback (/Users/konsumer/Desktop/test/node_modules/google-spreadsheets/node_modules/request/request.js:121:22)
    at Request.EventEmitter.emit (events.js:98:17)
    at Request.<anonymous> (/Users/konsumer/Desktop/test/node_modules/google-spreadsheets/node_modules/request/request.js:985:14)
    at Request.EventEmitter.emit (events.js:117:20)
    at IncomingMessage.<anonymous> (/Users/konsumer/Desktop/test/node_modules/google-spreadsheets/node_modules/request/request.js:936:12)
    at IncomingMessage.EventEmitter.emit (events.js:117:20)
    at _stream_readable.js:919:16

Am I doing it wrong, or does this library not work with google drive, anymore?

samcday commented 10 years ago

As per the README, did you make sure the spreadsheet is both published to the web and publicly viewable? This is done in two separate areas of the spreadsheets UI.

konsumer commented 10 years ago

Ah, that did it. That seems like a lil bit obtuse to me. If you have access to the URL (and the content) why do you need to also publish it (make it available on indexes)?

samcday commented 10 years ago

@konsumer no clue, it's just the way it is ;) If you authenticate the client (as per the README), then the weird subtleties pretty much go away entirely.

konsumer commented 10 years ago

Cool. I will try it out. Thanks.