paulirish / pwmetrics

Progressive web metrics at your fingertipz
Apache License 2.0
1.25k stars 74 forks source link

Google sheets API error? #228

Open timstallmann opened 4 years ago

timstallmann commented 4 years ago

Config / CLI options

When trying to upload results to Google Sheets, I get that the API returned an error -- google.sheets is not a function. Is this related to maybe updates in the sheets API?

Steps to reproduce.

Stack trace

Screenshot

The API returned an error: TypeError: google.sheets is not a function
Error: TypeError: google.sheets is not a function
    at Object.appendResults (/Users/tim/htdocs/quality-of-life-dashboard/node_modules/pwmetrics/lib/sheets/gsheets.js:51:15)
    at Sheets.appendResultsToGSheets (/Users/tim/htdocs/quality-of-life-dashboard/node_modules/pwmetrics/lib/sheets/index.js:61:27)
    at async PWMetrics.start (/Users/tim/htdocs/quality-of-life-dashboard/node_modules/pwmetrics/lib/index.js:77:17)

Environment

  1. pwmetrics version: 4.2.3
  2. Chrome version:
  3. OS version:
csb324 commented 4 years ago

I got the same error. If you go to gsheets.js and change const google = require('googleapis'); to const { google } = require('googleapis');

...it solves this problem, but then I run into a bunch of other problems (related to OAuth and callbacks not being defined and google's various packages not interacting with each other the way they're supposed to) which may or may not even be related. So, you can try this! But no promises it'll work, because it's not working for me haha

csb324 commented 4 years ago

Update! @timstallmann I just added a PR with the google npm package updates that solved this for me. take a look if you're still trying to get this working

timstallmann commented 4 years ago

@csb324 :stars: :fireworks: this is the best news I've gotten all day! I think the linter is just choking on the async keyword in line 98 of sheets.js.

timstallmann commented 4 years ago

Hmm I'm still getting now an invalid grant API response. @csb324 were you able to get this to work all the way through with an actual google sheet upload? I'm wondering if it's a problem on my end..

nathanmillar16 commented 4 years ago

Hi @timstallmann & @csb324 . Did this issue get resolved? I cloned the work done in @csb324 PR, recompiled the TS and I am getting error:

The API returned an error: Error: Unable to parse range: pwmetrics for demo!A1:C1 Error: Error: Unable to parse range: pwmetrics for demo!A1:C1 at GSheets.appendResults in \lib\sheets\gsheets.js\

nathanmillar16 commented 4 years ago

I apologise. I had the wrong config

timstallmann commented 4 years ago

Oh nice! @nathanmillar16 how did you fix your config? I'm still stuck on this error.

nathanmillar16 commented 4 years ago

Sorry for late reply. I had the table name in my package-config incorrect. It is supposed to match a tab within the sheets you're adding too.