mumblebaj / MMM-NewsAPI

MagicMirror² module - displaying news articles from Newsapi.org API V2
MIT License
7 stars 5 forks source link

Getting a strange error message from MMM-NewsAPI #2

Closed cybermaverick closed 2 years ago

cybermaverick commented 2 years ago

Hi, I installed the module but don't get any news. When checking the browser console I see the following error:

MMM-NewsAPI.js:134 Uncaught TypeError: Cannot read properties of undefined (reading 'sourceId') at Class.draw (MMM-NewsAPI.js:134) at Class.socketNotificationReceived (MMM-NewsAPI.js:100) at module.js:245 at Socket.<anonymous> (socketclient.js:38) at Socket../node_modules/component-emitter/index.js.Emitter.emit (index.js:145) at Socket.emit (typed-events.js:46) at Socket.emitEvent (socket.js:258) at Socket.onevent (socket.js:245) at Socket.MMSocket.socket.onevent (socketclient.js:32) at Socket.onpacket (socket.js:209)

Can you help me fixing this?

Thanks in advance

mumblebaj commented 2 years ago

Can you share the config you are using

cybermaverick commented 2 years ago

{ module: "MMM-NewsAPI", header: "NEWS", position: "bottom_left", config: { apiKey: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", type: "horizontal", choice: "headlines", pageSize: 10, drawInterval: 1000*30, templateFile: "template.html", fetchInterval: 1000*60*60, query: { country: "de", category: "", q: "", qInTitle: "", sources: "", domains: "", excludeDomains: "", language: "" } } },

mumblebaj commented 2 years ago

Hi. I have had some time to check out your issue and your config works fine for me. I would use position bottom_bar for better display. Other than that the module works fine. Is this a new installation? Did you follow all the steps, i.e. cd ~/MagicMirror/modules/MMM-NewsAPI/ and thennpm install?

{
        module: "MMM-NewsAPI",
        header: "news",
        position: "bottom_left",
        config: {
                apiKey: "YOUR API KEY GOES HERE",
                type: "horizontal",
                choice: "headlines",
                pageSize: 10,
                drawInterval: 1000*30,
                templateFile: "template.html",
                fetchInterval: 1000*60*60,
                query: {
                        country: "de",
                        category: "",
                        q: "",
                        qInTitle: "",
                        sources: "",
                        domains: "",
                        excludeDomains: "",
                        language: ""
                        }
                }
},
cybermaverick commented 2 years ago

Thanks for your quick reply. Yes, it's a new installation and I did npm install. I will reinstall it and check what happens.

mumblebaj commented 2 years ago

Please let me know. I am in South Africa and I only get to my email and GIT in the evenings. When I used your config as is, it worked fine for me. The error says that it expects information in the response coming back but there is nothing. i.e. the undefined for sourceId. This could be that it fails to get anything from the API call or that the required dependency modules have not been installed. If you still don't come right, you can try to add some Debug to the config file so we can get more info logged.

logLevel: ["INFO", "LOG", "WARN", "ERROR", "DEBUG"],