Fabrizz / MMM-OnSpotify

Highly customizable MM2 module that displays what you are listening to in Spotify. Compatible with MMM-LiveLyrics and DynamicTheming.
MIT License
53 stars 9 forks source link

this.fetcher undefined, [with suggestion for an easy fix] #28

Closed IdoPrinc3 closed 9 months ago

IdoPrinc3 commented 9 months ago

error

https://github.com/Fabrizz/MMM-OnSpotify/blob/d0db7cad518e14fd61d15478f49bce6b8d924158/node_helper.js#L50-L52

[27.09.2023 13:37.48.110] [ERROR] [MMM-NPOS] [Node Helper] >>  TypeError: Cannot read properties of undefined (reading 'getData')
    at Class.fetchSpotifyData (/home/ido/MagicMirror/modules/MMM-OnSpotify/node_helper.js:52:37)
    at Class.socketNotificationReceived (/home/ido/MagicMirror/modules/MMM-OnSpotify/node_helper.js:33:14)
    at Socket.<anonymous> (/home/ido/MagicMirror/js/node_helper.js:104:11)
    at Socket.emit (node:events:517:28)
    at Socket.emitUntyped (/home/ido/MagicMirror/node_modules/socket.io/dist/typed-events.js:69:22)
    at /home/ido/MagicMirror/node_modules/socket.io/dist/socket.js:703:39
    at process.processTicksAndRejections (node:internal/process/task_queues:77:11)

possible fix

Just an if statment checking for undefined or null

fetchSpotifyData: async function (type) {
    if (!this.fetcher)
      return;
    try {
      let data = await this.fetcher.getData(type);

packages version

npm list --depth=0

mmm-onspotify@2.3.1 /home/ido/MagicMirror/modules/MMM-OnSpotify
├── body-parser@1.20.2
├── cookie-parser@1.4.6
├── dompurify@3.0.5
├── express@4.18.2
├── moment-duration-format@2.3.2
├── moment@2.29.4
├── node-fetch@2.7.0
├── querystring@0.2.1
└── request@2.88.2