const fetchLeagueNames = async () => {
    try {
      const response = await fetch(`${API_BASE_URL}/api/league-names`);
      if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
      const data: { [key: string]: string } = await response.json();
      setLiveScores(prevScores => {
        const updatedScores: LiveScores = {};
        Object.keys(prevScores).forEach(oldLeague => {
          const newLeague = data[oldLeague] || oldLeague;
          updatedScores[newLeague] = prevScores[oldLeague];
        });
        return updatedScores;
      });
    } catch (error) {
      console.error("League fetching error:", error);
    }
  };
Basically I think this function is not working 
 const response = await fetch(`${API_BASE_URL}/api/scores`);
const filteredMatches = response.data.matches.map((match) => {
      const leagueName = leagueIds[match.competition.id] || "Other";
      return {
        id: match.id,
        utcDate: match.utcDate,
        status: match.status,
        league: leagueName,
        homeTeam: match.homeTeam,
        awayTeam: match.awayTeam,
        score: match.score,
        odds: Math.random().toFixed(2), // Mock data
        avgP: (Math.random() * 100).toFixed(2), // Mock data
        avgG: (Math.random() * 5).toFixed(2), // Mock data
        cG: Math.floor(Math.random() * 10), // Mock data
        BTS: Math.random() > 0.5 ? "Yes" : "No", // Mock data
        FTS: Math.random() > 0.5 ? "Yes" : "No", // Mock data
        "c>2,5": Math.random() > 0.5 ? "Yes" : "No", // Mock data
      };
    });
const groupedMatches = filteredMatches.reduce((acc, match) => {
      if (!acc[match.league]) {
        acc[match.league] = [];
      }
      acc[match.league].push(match);
      return acc;
    }, {});

    // Cache the live scores with a shorter TTL (e.g., 2 minutes)
    cache.set("liveScores", groupedMatches, 120);

    console.log("Cached live scores");

    res.status(200).json(groupedMatches);
  } catch (error) {
    console.error("Error fetching live scores:", error.message);
    res.status(500).json({
      message: "Unable to retrieve live scores. Please try again later.",
    });
  }
}

module.exports = scoresController;
my controller is of this type and Now tell me why it is not showing me 
{
    "Serie A": [
        {
            "id": 503099,
            "utcDate": "2024-09-30T18:45:00Z",
            "status": "IN_PLAY",
            "league": "Serie A",
            "homeTeam": {
                "id": 112,
                "name": "Parma Calcio 1913",
                "shortName": "Parma",
                "tla": "PAR",
                "crest": "https://crests.football-data.org/112.png"
            },
            "awayTeam": {
                "id": 104,
                "name": "Cagliari Calcio",
                "shortName": "Cagliari",
                "tla": "CAG",
                "crest": "https://crests.football-data.org/104.png"
            },
            "score": {
                "winner": "AWAY_TEAM",
                "duration": "REGULAR",
                "fullTime": {
                    "home": 0,
                    "away": 1
                },
                "halfTime": {
                    "home": null,
                    "away": null
                }
            },
            "odds": "0.33",
            "avgP": "5.55",
            "avgG": "3.25",
            "cG": 8,
            "BTS": "No",
            "FTS": "No",
            "c>2,5": "Yes"
        },
        {
            "id": 503111,
            "utcDate": "2024-10-04T16:30:00Z",
            "status": "TIMED",
            "league": "Serie A",
            "homeTeam": {
                "id": 113,
                "name": "SSC Napoli",
                "shortName": "Napoli",
                "tla": "NAP",
                "crest": "https://crests.football-data.org/113.png"
            },
            "awayTeam": {
                "id": 7397,
                "name": "Como 1907",
                "shortName": "Como 1907",
                "tla": "COM",
                "crest": "https://crests.football-data.org/7397.png"
            },
            "score": {
                "winner": null,
                "duration": "REGULAR",
                "fullTime": {
                    "home": null,
                    "away": null
                },
                "halfTime": {
                    "home": null,
                    "away": null
                }
            },
            "odds": "0.85",
            "avgP": "24.54",
            "avgG": "0.59",
            "cG": 7,
            "BTS": "No",
            "FTS": "No",
            "c>2,5": "Yes"
        },
        {
            "id": 503106,
            "utcDate": "2024-10-04T18:45:00Z",
            "status": "TIMED",
            "league": "Serie A",
            "homeTeam": {
                "id": 450,
                "name": "Hellas Verona FC",
                "shortName": "Verona",
                "tla": "HVE",
                "crest": "https://crests.football-data.org/450.png"
            },
            "awayTeam": {
                "id": 454,
                "name": "Venezia FC",
                "shortName": "Venezia FC",
                "tla": "VEN",
                "crest": "https://crests.football-data.org/454.png"
            },
            "score": {
                "winner": null,
                "duration": "REGULAR",
                "fullTime": {
                    "home": null,
                    "away": null
                },
                "halfTime": {
                    "home": null,
                    "away": null
                }
            },
            "odds": "0.12",
            "avgP": "2.82",
            "avgG": "1.39",
            "cG": 7,
            "BTS": "No",
            "FTS": "Yes",
            "c>2,5": "No"
        },
        {
            "id": 503112,
            "utcDate": "2024-10-05T13:00:00Z",
            "status": "TIMED",
            "league": "Serie A",
            "homeTeam": {
                "id": 115,
                "name": "Udinese Calcio",
                "shortName": "Udinese",
                "tla": "UDI",
                "crest": "https://crests.football-data.org/115.png"
            },
            "awayTeam": {
                "id": 5890,
                "name": "US Lecce",
                "shortName": "Lecce",
                "tla": "USL",
                "crest": "https://crests.football-data.org/5890.png"
            },
            "score": {
                "winner": null,
                "duration": "REGULAR",
                "fullTime": {
                    "home": null,
                    "away": null
                },
                "halfTime": {
                    "home": null,
                    "away": null
                }
            },
            "odds": "0.75",
            "avgP": "70.64",
            "avgG": "1.41",
            "cG": 3,
            "BTS": "No",
            "FTS": "Yes",
            "c>2,5": "Yes"
        },
        {
            "id": 503103,
            "utcDate": "2024-10-05T16:00:00Z",
            "status": "TIMED",
            "league": "Serie A",
            "homeTeam": {
                "id": 102,
                "name": "Atalanta BC",
                "shortName": "Atalanta",
                "tla": "ATA",
                "crest": "https://crests.football-data.org/102.png"
            },
            "awayTeam": {
                "id": 107,
                "name": "Genoa CFC",
                "shortName": "Genoa",
                "tla": "GEN",
                "crest": "https://crests.football-data.org/107.png"
            },
            "score": {
                "winner": null,
                "duration": "REGULAR",
                "fullTime": {
                    "home": null,
                    "away": null
                },
                "halfTime": {
                    "home": null,
                    "away": null
                }
            },
            "odds": "0.20",
            "avgP": "92.20",
            "avgG": "4.45",
            "cG": 2,
            "BTS": "Yes",
            "FTS": "Yes",
            "c>2,5": "No"
        },
        {
            "id": 503107,
            "utcDate": "2024-10-05T18:45:00Z",
            "status": "TIMED",
            "league": "Serie A",
            "homeTeam": {
                "id": 108,
                "name": "FC Internazionale Milano",
                "shortName": "Inter",
                "tla": "INT",
                "crest": "https://crests.football-data.org/108.png"
            },
            "awayTeam": {
                "id": 586,
                "name": "Torino FC",
                "shortName": "Torino",
                "tla": "TOR",
                "crest": "https://crests.football-data.org/586.png"
            },
            "score": {
                "winner": null,
                "duration": "REGULAR",
                "fullTime": {
                    "home": null,
                    "away": null
                },
                "halfTime": {
                    "home": null,
                    "away": null
                }
            },
            "odds": "0.74",
            "avgP": "91.22",
            "avgG": "4.08",
            "cG": 6,
            "BTS": "No",
            "FTS": "No",
            "c>2,5": "Yes"
        },
        {
            "id": 503108,
            "utcDate": "2024-10-06T10:30:00Z",
            "status": "TIMED",
            "league": "Serie A",
            "homeTeam": {
                "id": 109,
                "name": "Juventus FC",
                "shortName": "Juventus",
                "tla": "JUV",
                "crest": "https://crests.football-data.org/109.png"
            },
            "awayTeam": {
                "id": 104,
                "name": "Cagliari Calcio",
                "shortName": "Cagliari",
                "tla": "CAG",
                "crest": "https://crests.football-data.org/104.png"
            },
            "score": {
                "winner": null,
                "duration": "REGULAR",
                "fullTime": {
                    "home": null,
                    "away": null
                },
                "halfTime": {
                    "home": null,
                    "away": null
                }
            },
            "odds": "0.32",
            "avgP": "15.62",
            "avgG": "3.85",
            "cG": 6,
            "BTS": "No",
            "FTS": "Yes",
            "c>2,5": "No"
        },
        {
            "id": 503109,
            "utcDate": "2024-10-06T13:00:00Z",
            "status": "TIMED",
            "league": "Serie A",
            "homeTeam": {
                "id": 110,
                "name": "SS Lazio",
                "shortName": "Lazio",
                "tla": "LAZ",
                "crest": "https://crests.football-data.org/110.png"
            },
            "awayTeam": {
                "id": 445,
                "name": "Empoli FC",
                "shortName": "Empoli",
                "tla": "EMP",
                "crest": "https://crests.football-data.org/445.png"
            },
            "score": {
                "winner": null,
                "duration": "REGULAR",
                "fullTime": {
                    "home": null,
                    "away": null
                },
                "halfTime": {
                    "home": null,
                    "away": null
                }
            },
            "odds": "0.20",
            "avgP": "99.59",
            "avgG": "1.33",
            "cG": 7,
            "BTS": "No",
            "FTS": "Yes",
            "c>2,5": "No"
        },
        {
            "id": 503104,
            "utcDate": "2024-10-06T13:00:00Z",
            "status": "TIMED",
            "league": "Serie A",
            "homeTeam": {
                "id": 103,
                "name": "Bologna FC 1909",
                "shortName": "Bologna",
                "tla": "BOL",
                "crest": "https://crests.football-data.org/103.png"
            },
            "awayTeam": {
                "id": 112,
                "name": "Parma Calcio 1913",
                "shortName": "Parma",
                "tla": "PAR",
                "crest": "https://crests.football-data.org/112.png"
            },
            "score": {
                "winner": null,
                "duration": "REGULAR",
                "fullTime": {
                    "home": null,
                    "away": null
                },
                "halfTime": {
                    "home": null,
                    "away": null
                }
            },
            "odds": "0.95",
            "avgP": "85.19",
            "avgG": "1.59",
            "cG": 2,
            "BTS": "No",
            "FTS": "No",
            "c>2,5": "Yes"
        },
        {
            "id": 503110,
            "utcDate": "2024-10-06T16:00:00Z",
            "status": "TIMED",
            "league": "Serie A",
            "homeTeam": {
                "id": 5911,
                "name": "AC Monza",
                "shortName": "Monza",
                "tla": "MON",
                "crest": "https://crests.football-data.org/5911.png"
            },
            "awayTeam": {
                "id": 100,
                "name": "AS Roma",
                "shortName": "Roma",
                "tla": "ROM",
                "crest": "https://crests.football-data.org/100.png"
            },
            "score": {
                "winner": null,
                "duration": "REGULAR",
                "fullTime": {
                    "home": null,
                    "away": null
                },
                "halfTime": {
                    "home": null,
                    "away": null
                }
            },
            "odds": "0.86",
            "avgP": "89.87",
            "avgG": "2.15",
            "cG": 8,
            "BTS": "No",
            "FTS": "Yes",
            "c>2,5": "No"
        },
        {
            "id": 503105,
            "utcDate": "2024-10-06T18:45:00Z",
            "status": "TIMED",
            "league": "Serie A",
            "homeTeam": {
                "id": 99,
                "name": "ACF Fiorentina",
                "shortName": "Fiorentina",
                "tla": "FIO",
                "crest": "https://crests.football-data.org/99.png"
            },
            "awayTeam": {
                "id": 98,
                "name": "AC Milan",
                "shortName": "Milan",
                "tla": "MIL",
                "crest": "https://crests.football-data.org/98.png"
            },
            "score": {
                "winner": null,
                "duration": "REGULAR",
                "fullTime": {
                    "home": null,
                    "away": null
                },
                "halfTime": {
                    "home": null,
                    "away": null
                }
            },
            "odds": "0.60",
            "avgP": "81.78",
            "avgG": "3.58",
            "cG": 4,
            "BTS": "Yes",
            "FTS": "No",
            "c>2,5": "Yes"
        }
    ],
    "La Liga": [
        {
            "id": 498688,
            "utcDate": "2024-09-30T19:00:00Z",
            "status": "IN_PLAY",
            "league": "La Liga",
            "homeTeam": {
                "id": 94,
                "name": "Villarreal CF",
                "shortName": "Villarreal",
                "tla": "VIL",
                "crest": "https://crests.football-data.org/94.png"
            },
            "awayTeam": {
                "id": 275,
                "name": "UD Las Palmas",
                "shortName": "Las Palmas",
                "tla": "LPA",
                "crest": "https://crests.football-data.org/275.png"
            },
            "score": {
                "winner": "DRAW",
                "duration": "REGULAR",
                "fullTime": {
                    "home": 0,
                    "away": 0
                },
                "halfTime": {
                    "home": null,
                    "away": null
                }
            },
            "odds": "0.39",
            "avgP": "85.57",
            "avgG": "2.28",
            "cG": 7,
            "BTS": "No",
            "FTS": "Yes",
            "c>2,5": "Yes"
        },
        {
            "id": 498693,
            "utcDate": "2024-10-04T19:00:00Z",
            "status": "TIMED",
            "league": "La Liga",
            "homeTeam": {
                "id": 745,
                "name": "CD Leganés",
                "shortName": "Leganés",
                "tla": "LEG",
                "crest": "https://crests.football-data.org/745.png"
            },
            "awayTeam": {
                "id": 95,
                "name": "Valencia CF",
                "shortName": "Valencia",
                "tla": "VAL",
                "crest": "https://crests.football-data.org/95.png"
            },
            "score": {
                "winner": null,
                "duration": "REGULAR",
                "fullTime": {
                    "home": null,
                    "away": null
                },
                "halfTime": {
                    "home": null,
                    "away": null
                }
            },
            "odds": "0.47",
            "avgP": "28.76",
            "avgG": "1.15",
            "cG": 2,
            "BTS": "No",
            "FTS": "Yes",
            "c>2,5": "Yes"
        },
        {
            "id": 498702,
            "utcDate": "2024-10-05T12:00:00Z",
            "status": "TIMED",
            "league": "La Liga",
            "homeTeam": {
                "id": 80,
                "name": "RCD Espanyol de Barcelona",
                "shortName": "Espanyol",
                "tla": "ESP",
                "crest": "https://crests.football-data.org/80.png"
            },
            "awayTeam": {
                "id": 89,
                "name": "RCD Mallorca",
                "shortName": "Mallorca",
                "tla": "MAL",
                "crest": "https://crests.football-data.org/89.png"
            },
            "score": {
                "winner": null,
                "duration": "REGULAR",
                "fullTime": {
                    "home": null,
                    "away": null
                },
                "halfTime": {
                    "home": null,
                    "away": null
                }
            },
            "odds": "0.63",
            "avgP": "51.37",
            "avgG": "2.86",
            "cG": 5,
            "BTS": "Yes",
            "FTS": "No",
            "c>2,5": "No"
        },
        {
            "id": 498695,
            "utcDate": "2024-10-05T14:15:00Z",
            "status": "TIMED",
            "league": "La Liga",
            "homeTeam": {
                "id": 82,
                "name": "Getafe CF",
                "shortName": "Getafe",
                "tla": "GET",
                "crest": "https://crests.football-data.org/82.png"
            },
            "awayTeam": {
                "id": 79,
                "name": "CA Osasuna",
                "shortName": "Osasuna",
                "tla": "OSA",
                "crest": "https://crests.football-data.org/79.png"
            },
            "score": {
                "winner": null,
                "duration": "REGULAR",
                "fullTime": {
                    "home": null,
                    "away": null
                },
                "halfTime": {
                    "home": null,
                    "away": null
                }
            },
            "odds": "0.60",
            "avgP": "68.64",
            "avgG": "3.61",
            "cG": 2,
            "BTS": "No",
            "FTS": "Yes",
            "c>2,5": "Yes"
        },
        {
            "id": 498700,
            "utcDate": "2024-10-05T16:30:00Z",
            "status": "TIMED",
            "league": "La Liga",
            "homeTeam": {
                "id": 250,
                "name": "Real Valladolid CF",
                "shortName": "Valladolid",
                "tla": "VDD",
                "crest": "https://crests.football-data.org/250.png"
            },
            "awayTeam": {
                "id": 87,
                "name": "Rayo Vallecano de Madrid",
                "shortName": "Rayo Vallecano",
                "tla": "RAY",
                "crest": "https://crests.football-data.org/87.png"
            },
            "score": {
                "winner": null,
                "duration": "REGULAR",
                "fullTime": {
                    "home": null,
                    "away": null
                },
                "halfTime": {
                    "home": null,
                    "away": null
                }
            },
            "odds": "0.96",
            "avgP": "95.40",
            "avgG": "3.67",
            "cG": 9,
            "BTS": "No",
            "FTS": "Yes",
            "c>2,5": "No"
        },
        {
            "id": 498701,
            "utcDate": "2024-10-05T16:30:00Z",
            "status": "TIMED",
            "league": "La Liga",
            "homeTeam": {
                "id": 275,
                "name": "UD Las Palmas",
                "shortName": "Las Palmas",
                "tla": "LPA",
                "crest": "https://crests.football-data.org/275.png"
            },
            "awayTeam": {
                "id": 558,
                "name": "RC Celta de Vigo",
                "shortName": "Celta",
                "tla": "CEL",
                "crest": "https://crests.football-data.org/558.png"
            },
            "score": {
                "winner": null,
                "duration": "REGULAR",
                "fullTime": {
                    "home": null,
                    "away": null
                },
                "halfTime": {
                    "home": null,
                    "away": null
                }
            },
            "odds": "0.35",
            "avgP": "54.73",
            "avgG": "2.23",
            "cG": 9,
            "BTS": "No",
            "FTS": "Yes",
            "c>2,5": "No"
        },
        {
            "id": 498698,
            "utcDate": "2024-10-05T19:00:00Z",
            "status": "TIMED",
            "league": "La Liga",
            "homeTeam": {
                "id": 86,
                "name": "Real Madrid CF",
                "shortName": "Real Madrid",
                "tla": "RMA",
                "crest": "https://crests.football-data.org/86.png"
            },
            "awayTeam": {
                "id": 94,
                "name": "Villarreal CF",
                "shortName": "Villarreal",
                "tla": "VIL",
                "crest": "https://crests.football-data.org/94.png"
            },
            "score": {
                "winner": null,
                "duration": "REGULAR",
                "fullTime": {
                    "home": null,
                    "away": null
                },
                "halfTime": {
                    "home": null,
                    "away": null
                }
            },
            "odds": "0.39",
            "avgP": "25.82",
            "avgG": "2.21",
            "cG": 1,
            "BTS": "Yes",
            "FTS": "Yes",
            "c>2,5": "Yes"
        },
        {
            "id": 498696,
            "utcDate": "2024-10-06T12:00:00Z",
            "status": "TIMED",
            "league": "La Liga",
            "homeTeam": {
                "id": 298,
                "name": "Girona FC",
                "shortName": "Girona",
                "tla": "GIR",
                "crest": "https://crests.football-data.org/298.png"
            },
            "awayTeam": {
                "id": 77,
                "name": "Athletic Club",
                "shortName": "Athletic",
                "tla": "ATH",
                "crest": "https://crests.football-data.org/77.png"
            },
            "score": {
                "winner": null,
                "duration": "REGULAR",
                "fullTime": {
                    "home": null,
                    "away": null
                },
                "halfTime": {
                    "home": null,
                    "away": null
                }
            },
            "odds": "0.73",
            "avgP": "49.62",
            "avgG": "1.66",
            "cG": 6,
            "BTS": "Yes",
            "FTS": "No",
            "c>2,5": "No"
        },
        {
            "id": 498694,
            "utcDate": "2024-10-06T14:15:00Z",
            "status": "TIMED",
            "league": "La Liga",
            "homeTeam": {
                "id": 263,
                "name": "Deportivo Alavés",
                "shortName": "Alavés",
                "tla": "ALA",
                "crest": "https://crests.football-data.org/263.png"
            },
            "awayTeam": {
                "id": 81,
                "name": "FC Barcelona",
                "shortName": "Barça",
                "tla": "FCB",
                "crest": "https://crests.football-data.org/81.png"
            },
            "score": {
                "winner": null,
                "duration": "REGULAR",
                "fullTime": {
                    "home": null,
                    "away": null
                },
                "halfTime": {
                    "home": null,
                    "away": null
                }
            },
            "odds": "0.16",
            "avgP": "84.76",
            "avgG": "2.71",
            "cG": 3,
            "BTS": "Yes",
            "FTS": "No",
            "c>2,5": "No"
        },
        {
            "id": 498697,
            "utcDate": "2024-10-06T16:30:00Z",
            "status": "TIMED",
            "league": "La Liga",
            "homeTeam": {
                "id": 559,
                "name": "Sevilla FC",
                "shortName": "Sevilla FC",
                "tla": "SEV",
                "crest": "https://crests.football-data.org/559.png"
            },
            "awayTeam": {
                "id": 90,
                "name": "Real Betis Balompié",
                "shortName": "Real Betis",
                "tla": "BET",
                "crest": "https://crests.football-data.org/90.png"
            },
            "score": {
                "winner": null,
                "duration": "REGULAR",
                "fullTime": {
                    "home": null,
                    "away": null
                },
                "halfTime": {
                    "home": null,
                    "away": null
                }
            },
            "odds": "0.46",
            "avgP": "33.91",
            "avgG": "2.88",
            "cG": 8,
            "BTS": "No",
            "FTS": "Yes",
            "c>2,5": "Yes"
        },
        {
            "id": 498699,
            "utcDate": "2024-10-06T19:00:00Z",
            "status": "TIMED",
            "league": "La Liga",
            "homeTeam": {
                "id": 92,
                "name": "Real Sociedad de Fútbol",
                "shortName": "Real Sociedad",
                "tla": "RSO",
                "crest": "https://crests.football-data.org/92.png"
            },
            "awayTeam": {
                "id": 78,
                "name": "Club Atlético de Madrid",
                "shortName": "Atleti",
                "tla": "ATL",
                "crest": "https://crests.football-data.org/78.png"
            },
            "score": {
                "winner": null,
                "duration": "REGULAR",
                "fullTime": {
                    "home": null,
                    "away": null
                },
                "halfTime": {
                    "home": null,
                    "away": null
                }
            },
            "odds": "0.28",
            "avgP": "81.29",
            "avgG": "2.57",
            "cG": 7,
            "BTS": "Yes",
            "FTS": "Yes",
            "c>2,5": "No"
        }
    ],
    "Premier League": [
        {
            "id": 497460,
            "utcDate": "2024-09-30T19:00:00Z",
            "status": "IN_PLAY",
            "league": "Premier League",
            "homeTeam": {
                "id": 1044,
                "name": "AFC Bournemouth",
                "shortName": "Bournemouth",
                "tla": "BOU",
                "crest": "https://crests.football-data.org/bournemouth.png"
            },
            "awayTeam": {
                "id": 340,
                "name": "Southampton FC",
                "shortName": "Southampton",
                "tla": "SOU",
                "crest": "https://crests.football-data.org/340.png"
            },
            "score": {
                "winner": "DRAW",
                "duration": "REGULAR",
                "fullTime": {
                    "home": 0,
                    "away": 0
                },
                "halfTime": {
                    "home": null,
                    "away": null
                }
            },
            "odds": "0.82",
            "avgP": "82.68",
            "avgG": "4.68",
            "cG": 6,
            "BTS": "Yes",
            "FTS": "Yes",
            "c>2,5": "No"
        },
        {
            "id": 497475,
            "utcDate": "2024-10-05T11:30:00Z",
            "status": "TIMED",
            "league": "Premier League",
            "homeTeam": {
                "id": 354,
                "name": "Crystal Palace FC",
                "shortName": "Crystal Palace",
                "tla": "CRY",
                "crest": "https://crests.football-data.org/354.png"
            },
            "awayTeam": {
                "id": 64,
                "name": "Liverpool FC",
                "shortName": "Liverpool",
                "tla": "LIV",
                "crest": "https://crests.football-data.org/64.png"
            },
            "score": {
                "winner": null,
                "duration": "REGULAR",
                "fullTime": {
                    "home": null,
                    "away": null
                },
                "halfTime": {
                    "home": null,
                    "away": null
                }
            },
            "odds": "0.05",
            "avgP": "76.95",
            "avgG": "1.26",
            "cG": 2,
            "BTS": "Yes",
            "FTS": "Yes",
            "c>2,5": "Yes"
        },
        {
            "id": 497470,
            "utcDate": "2024-10-05T14:00:00Z",
            "status": "TIMED",
            "league": "Premier League",
            "homeTeam": {
                "id": 57,
                "name": "Arsenal FC",
                "shortName": "Arsenal",
                "tla": "ARS",
                "crest": "https://crests.football-data.org/57.png"
            },
            "awayTeam": {
                "id": 340,
                "name": "Southampton FC",
                "shortName": "Southampton",
                "tla": "SOU",
                "crest": "https://crests.football-data.org/340.png"
            },
            "score": {
                "winner": null,
                "duration": "REGULAR",
                "fullTime": {
                    "home": null,
                    "away": null
                },
                "halfTime": {
                    "home": null,
                    "away": null
                }
            },
            "odds": "0.98",
            "avgP": "83.53",
            "avgG": "1.51",
            "cG": 0,
            "BTS": "No",
            "FTS": "No",
            "c>2,5": "No"
        },
        {
            "id": 497478,
            "utcDate": "2024-10-05T14:00:00Z",
            "status": "TIMED",
            "league": "Premier League",
            "homeTeam": {
                "id": 65,
                "name": "Manchester City FC",
                "shortName": "Man City",
                "tla": "MCI",
                "crest": "https://crests.football-data.org/65.png"
            },
            "awayTeam": {
                "id": 63,
                "name": "Fulham FC",
                "shortName": "Fulham",
                "tla": "FUL",
                "crest": "https://crests.football-data.org/63.png"
            },
            "score": {
                "winner": null,
                "duration": "REGULAR",
                "fullTime": {
                    "home": null,
                    "away": null
                },
                "halfTime": {
                    "home": null,
                    "away": null
                }
            },
            "odds": "0.24",
            "avgP": "68.26",
            "avgG": "1.30",
            "cG": 5,
            "BTS": "Yes",
            "FTS": "Yes",
            "c>2,5": "No"
        },
        {
            "id": 497472,
            "utcDate": "2024-10-05T14:00:00Z",
            "status": "TIMED",
            "league": "Premier League",
            "homeTeam": {
                "id": 402,
                "name": "Brentford FC",
                "shortName": "Brentford",
                "tla": "BRE",
                "crest": "https://crests.football-data.org/402.png"
            },
            "awayTeam": {
                "id": 76,
                "name": "Wolverhampton Wanderers FC",
                "shortName": "Wolverhampton",
                "tla": "WOL",
                "crest": "https://crests.football-data.org/76.png"
            },
            "score": {
                "winner": null,
                "duration": "REGULAR",
                "fullTime": {
                    "home": null,
                    "away": null
                },
                "halfTime": {
                    "home": null,
                    "away": null
                }
            },
            "odds": "0.71",
            "avgP": "56.33",
            "avgG": "3.99",
            "cG": 7,
            "BTS": "No",
            "FTS": "No",
            "c>2,5": "Yes"
        },
        {
            "id": 497477,
            "utcDate": "2024-10-05T14:00:00Z",
            "status": "TIMED",
            "league": "Premier League",
            "homeTeam": {
                "id": 338,
                "name": "Leicester City FC",
                "shortName": "Leicester City",
                "tla": "LEI",
                "crest": "https://crests.football-data.org/338.png"
            },
            "awayTeam": {
                "id": 1044,
                "name": "AFC Bournemouth",
                "shortName": "Bournemouth",
                "tla": "BOU",
                "crest": "https://crests.football-data.org/bournemouth.png"
            },
            "score": {
                "winner": null,
                "duration": "REGULAR",
                "fullTime": {

response at http://localhost:5000/api/scores Tell me why  
'use client'

import React, { useState, useEffect } from 'react';
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Skeleton } from "@/components/ui/skeleton";
import { motion, AnimatePresence } from "framer-motion";
import { RefreshCw, ChevronDown, ChevronUp } from 'lucide-react';

const API_BASE_URL = 'http://localhost:5000';
const SCORE_REFRESH_DELAY = 60000; // 1 minute for scores
const TEAM_REFRESH_DELAY = 300000; // 5 minutes for team names
const LEAGUE_REFRESH_DELAY = 3600000; // 1 hour for league names

interface Team {
  id: number;
  name: string;
  shortName: string;
  tla: string;
  crest: string;
}

interface Score {
  winner: string | null;
  duration: string;
  fullTime: {
    home: number | null;
    away: number | null;
  };
  halfTime: {
    home: number | null;
    away: number | null;
  };
}

interface Match {
  id: number;
  utcDate: string;
  status: string;
  homeTeam: Team;
  awayTeam: Team;
  score: Score;
}

interface LiveScores {
  [key: string]: Match[];
}

const leagueColors: { [key: string]: string } = {
  'UEFA Champions League': 'bg-gradient-to-r from-blue-600 to-blue-400',
  'UEFA Europa League': 'bg-gradient-to-r from-orange-600 to-black',
  'Premier League': 'bg-gradient-to-r from-purple-600 to-blue-600',
  'La Liga': 'bg-gradient-to-r from-red-600 to-yellow-600',
  'Serie A': 'bg-gradient-to-r from-blue-600 to-green-600',
  'Bundesliga': 'bg-gradient-to-r from-red-600 to-gray-600',
  'Ligue 1': 'bg-gradient-to-r from-blue-600 to-red-600',
  'Other': 'bg-gradient-to-r from-gray-600 to-gray-400'
};

const leagueOrder = [
  'UEFA Champions League',
  'UEFA Europa League',
  'Premier League',
  'La Liga',
  'Serie A',
  'Bundesliga',
  'Ligue 1',
  'Other'
];

export default function LiveScore() {
  const [liveScores, setLiveScores] = useState<LiveScores>({});
  const [error, setError] = useState<string | null>(null);
  const [isLoading, setIsLoading] = useState(true);
  const [lastTeamFetch, setLastTeamFetch] = useState(0);
  const [lastLeagueFetch, setLastLeagueFetch] = useState(0);
  const [expandedLeagues, setExpandedLeagues] = useState<{ [key: string]: boolean }>({});

  const fetchLiveScores = async () => {
    setIsLoading(true);
    try {
      const response = await fetch(`${API_BASE_URL}/api/scores`);
      if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
      const data: LiveScores = await response.json();
      setLiveScores(data);
      setError(null);
    } catch (error) {
      console.error("Fetching error:", error);
      setError(error instanceof Error ? error.message : String(error));
    } finally {
      setIsLoading(false);
    }
  };

  const fetchTeamNames = async () => {
    try {
      const response = await fetch(`${API_BASE_URL}/api/team-names`);
      if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
      const data: { [key: number]: Team } = await response.json();
      setLiveScores(prevScores => {
        const updatedScores = { ...prevScores };
        Object.keys(updatedScores).forEach(league => {
          updatedScores[league] = updatedScores[league].map(match => ({
            ...match,
            homeTeam: data[match.homeTeam.id] || match.homeTeam,
            awayTeam: data[match.awayTeam.id] || match.awayTeam,
          }));
        });
        return updatedScores;
      });
    } catch (error) {
      console.error("Team fetching error:", error);
    }
  };

  const fetchLeagueNames = async () => {
    try {
      const response = await fetch(`${API_BASE_URL}/api/scores`);
      if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
      const data: { [key: string]: string } = await response.json();
      setLiveScores(prevScores => {
        const updatedScores: LiveScores = {};
        Object.keys(prevScores).forEach(oldLeague => {
          const newLeague = data[oldLeague] || oldLeague;
          updatedScores[newLeague] = prevScores[oldLeague];
        });
        return updatedScores;
      });
    } catch (error) {
      console.error("League fetching error:", error);
    }
  };

  useEffect(() => {
    fetchLiveScores();
    const intervalId = setInterval(() => {
      const now = Date.now();
      if (now - lastTeamFetch > TEAM_REFRESH_DELAY) {
        fetchTeamNames();
        setLastTeamFetch(now);
      }
      if (now - lastLeagueFetch > LEAGUE_REFRESH_DELAY) {
        fetchLeagueNames();
        setLastLeagueFetch(now);
      }
      fetchLiveScores();
    }, SCORE_REFRESH_DELAY);

    return () => clearInterval(intervalId);
  }, [lastTeamFetch, lastLeagueFetch]);

  const toggleLeagueExpansion = (league: string) => {
    setExpandedLeagues(prev => ({
      ...prev,
      [league]: !prev[league]
    }));
  };

  const MatchRow = ({ match }: { match: Match }) => (
    <div className="flex justify-between items-center py-2 border-b last:border-b-0">
      <div className="flex items-center space-x-2 w-5/12">
        <img src={match.homeTeam.crest} alt={match.homeTeam.name} className="w-4 h-4" />
        <span className="font-semibold text-sm">{match.homeTeam.name}</span>
      </div>
      <div className="flex flex-col items-center w-2/12">
        <div className="text-sm font-bold items-center">
          {match.score.fullTime.home ?? '-'} - {match.score.fullTime.away ?? '-'}
        </div>
        <div className="text-xs text-gray-500">
          {match.status === 'FINISHED' 
            ? 'FT' 
            : `${new Date(match.utcDate).toLocaleDateString([], { year: 'numeric', month: 'short', day: 'numeric' })} ${new Date(match.utcDate).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}`}
        </div>
      </div>
      <div className="flex items-center justify-end space-x-2 w-5/12">
        <span className="font-semibold text-sm">{match.awayTeam.name}</span>
        <img src={match.awayTeam.crest} alt={match.awayTeam.name} className="w-4 h-4" />
      </div>
    </div>
  );

  const LeagueCard = ({ league, matches }: { league: string, matches: Match[] }) => {
    const isExpanded = expandedLeagues[league];
    const visibleMatches = isExpanded ? matches : matches.slice(0, 3);

    return (
      <motion.div
        initial={{ opacity: 0, y: 20 }}
        animate={{ opacity: 1, y: 0 }}
        exit={{ opacity: 0, y: -20 }}
        transition={{ duration: 0.3 }}
        className="mb-4"
      >
        <Card className="overflow-hidden shadow-lg hover:shadow-xl transition-shadow duration-300">
          <CardHeader 
            className={`${leagueColors[league] || 'bg-gradient-to-r from-gray-600 to-gray-400'} text-white cursor-pointer hover:bg-opacity-80 transition duration-200`}
            onClick={() => toggleLeagueExpansion(league)}
            style={{ cursor: 'pointer' }}
          >
            <CardTitle className="text-xl flex items-center justify-between">
              <span>{league}</span>
              {isExpanded ? <ChevronUp size={20} /> : <ChevronDown size={20} />}
            </CardTitle>
          </CardHeader>
          <CardContent className="p-4">
            {visibleMatches.map((match) => (
              <MatchRow key={match.id} match={match} />
            ))}
            {!isExpanded && matches.length > 3 && (
              <div className="text-center mt-2 text-sm text-gray-500">
                {matches.length - 3} more matches
              </div>
            )}
          </CardContent>
        </Card>
      </motion.div>
    );
  };

  return (
    <div className="space-y-4 max-w-2xl mx-auto">
      <div className="flex justify-between items-center mb-6">
        <h2 className="text-3xl font-bold text-gray-800">Live Scores</h2>
        <motion.button
          whileHover={{ scale: 1.1 }}
          whileTap={{ scale: 0.9 }}
          onClick={() => window.location.reload()}
          className="p-2 rounded-full bg-blue-600 text-white hover:bg-blue-700 transition-colors duration-300"
        >
          <RefreshCw size={20} />
        </motion.button>
      </div>
      {isLoading ? (
        Array(3).fill(0).map((_, index) => (
          <Skeleton key={index} className="h-40 w-full mb-4" />
        ))
      ) : error ? (
        <Card className="bg-red-100 text-red-700 p-4">
          <CardContent>Error: {error}</CardContent>
        </Card>
      ) : (
        <AnimatePresence>
          {leagueOrder.map(league => 
            liveScores[league] && (
              <LeagueCard key={league} league={league} matches={liveScores[league]} />
            )
          )}
          {Object.keys(liveScores).length === 0 && (
            <motion.div
              initial={{ opacity: 0 }}
              animate={{ opacity: 1 }}
              exit={{ opacity: 0 }}
              className="text-center p-4 text-gray-600"
            >
              No live matches at the moment.
            </motion.div>
          )}
        </AnimatePresence>
      )}
    </div>
  );
}
This is my LiveScore.tsx controller whole