From f40bb7e501b57d427a4e8fe863d586886c2c9695 Mon Sep 17 00:00:00 2001 From: Max Bethge Date: Thu, 18 Jul 2024 10:22:51 -0700 Subject: [PATCH] Added handling of missing 'games' tag --- providers/SNET.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/providers/SNET.js b/providers/SNET.js index 79d02c5..e945e31 100644 --- a/providers/SNET.js +++ b/providers/SNET.js @@ -136,12 +136,17 @@ module.exports = { getLeague: function(league, teams) { console.log( "[MMM-MyScoreboard] " + moment().format("D-MMM-YY HH:mm") + " getLeague: " + league + ", " + teams ); var self = this; - - var filteredGames = this.scoresObj.data.games.filter(function(game) { - return(game.league.toUpperCase() == league.toUpperCase() && - (teams == null || teams.indexOf(game.home_team.short_name.toUpperCase()) != -1 || - teams.indexOf(game.visiting_team.short_name.toUpperCase()) != -1) ); - }); + + if(this.scoresObj.data.games) { + var filteredGames = this.scoresObj.data.games.filter(function(game) { + return(game.league.toUpperCase() == league.toUpperCase() && + (teams == null || teams.indexOf(game.home_team.short_name.toUpperCase()) != -1 || + teams.indexOf(game.visiting_team.short_name.toUpperCase()) != -1) ); + }); + } + else { + console.log( "[MMM-MyScoreboard] " + moment().format("D-MMM-YY HH:mm") + " getLeague: no games today"); + } /*