ryan-d-williams / MMM-GoogleSheets

Google Sheets Module for MagicMirror
MIT License
30 stars 2 forks source link

Mirror don't access sheet #55

Closed FallandeGubbe closed 1 month ago

FallandeGubbe commented 1 month ago

Hi, I have followed the instructions, but get error when applying:

"There was an error in the request: Request failed. Check the URL and logs for more information."

config:

{ module: "MMM-GoogleSheets", header: "Google Sheets", position: "top_right", config: { url: "https://script.google.com/macros/s/AKfycby6hghPqxI6DTgm3tNmsm2eaRWLVWTF5meCjmde4e3FbRxV79nxEGDebUqRBYrwNDPgUQ/exec", sheet: "Blad1", range: "D6:D10" } },

ryan-d-williams commented 1 month ago

@FallandeGubbe

When I try that exact config on my MM, it works as expected: image

A couple things you can try:

  1. Make sure you are restarting the MM after you change the config.
  2. Make sure this isn't a firewall issue on your pi. You should be able to view the following url in your browser on the raspberry pi (https://script.google.com/macros/s/AKfycby6hghPqxI6DTgm3tNmsm2eaRWLVWTF5meCjmde4e3FbRxV79nxEGDebUqRBYrwNDPgUQ/exec?sheet=Blad1&range=D6:D10). When you view that url you should see something like this: image
FallandeGubbe commented 1 month ago

Thanks for checking this and replying.

  1. yes , I always restart my mm after changing and saving config file

2, When accessing the url, you provided, from browser on R Pi running MM I get same result (success) , however when I click from my windows computer the file is not accessible. BUT in incognito mode it is !! But maybe that wont matter? As long as it is accessible from R Pi it should work?

ryan-d-williams commented 1 month ago

@FallandeGubbe

Yes as long as it is available on the pi it should work. This is not a problem with the module but rather a problem with something in your setup.

If you're comfortable with code, you can try printing out the requestError in the node_helper file. You can add a new line 53 that reads:

console.log(requestError)

That might give us some more info on exactly why the request is failing on your pi.

FallandeGubbe commented 1 month ago

ok, thanks. No I am far from a coder, but I added the code you suggested.

Same result - Would I be able so see a log file somewhere?

ryan-d-williams commented 1 month ago

@FallandeGubbe

That code would print the error to the developer console in the browser. If you don't know how to access that you can change that line you added to:

Log.info(requestError)

And it will then print to the terminal (where you start MM from)

FallandeGubbe commented 1 month ago

OK!

Does this help?

[20.10.2024 20:13.48.090] [LOG] [MMM-GoogleSheets] Sending request to https://script.google.com/macros/s/AKfycby6hghPqxI6DTgm3tNmsm2eaRWLVWTF5meCjmde4e3FbRxV79nxEGDebUqRBYrwNDPgUQ/exec?sheet=Blad1&range=D6:D10 [20.10.2024 20:13.48.109] [INFO] ReferenceError: fetch is not defined at Class.socketNotificationReceived (/home/pi/MagicMirror/modules/MMM-GoogleSheets/node_helper.js:28:24) at Socket. (/home/pi/MagicMirror/js/node_helper.js:109:11) at Socket.emit (events.js:315:20) at Socket.emitUntyped (/home/pi/MagicMirror/node_modules/socket.io/dist/typed-events.js:69:22) at /home/pi/MagicMirror/node_modules/socket.io/dist/socket.js:428:39 at processTicksAndRejections (internal/process/task_queues.js:79:11) [20.10.2024 20:13.48.125] [ERROR] [MMM-Google-Sheets] ERROR There was an error with the request at 20-Oct-24 20:13. This URL should work in your browser: https://script.google.com/macros/s/AKfycby6hghPqxI6DTgm3tNmsm2eaRWLVWTF5meCjmde4e3FbRxV79nxEGDebUqRBYrwNDPgUQ/exec?sheet=Blad1&range=D6:D10

ryan-d-williams commented 1 month ago

@FallandeGubbe

The key here is "ReferenceError: fetch is not defined".

It looks like you are using an incorrect (old) version of nodejs. You can confirm this by tying this in your terminal:

node -v

My guess is it will show a version <18. The fetch function was only introduced in nodejs 18+.

If you have an old node version, you need to upgrade.

If you have a current node version and it is still failing, you probably have an old version of MM (this thread talks about this exact problem).

ryan-d-williams commented 1 month ago

I'm going to close this issue since this is not a module problem. If you still can't get it to work feel free to open it back up in the future.