From 34e6d5cffa8d9e0400c20a8b33edda38292c7043 Mon Sep 17 00:00:00 2001 From: Ibrahim Ahmed Ali <113978782+Antitoxic9639@users.noreply.github.com> Date: Fri, 20 Dec 2024 08:33:12 +0100 Subject: [PATCH] Update fotmob extension (#15959) * fix fetching matchDay * Update CHANGELOG.md and optimise images --------- Co-authored-by: raycastbot --- extensions/fotmob/CHANGELOG.md | 5 +++++ extensions/fotmob/src/hooks/useMatchDay.ts | 4 +++- extensions/fotmob/src/hooks/useTeamDetail.ts | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/extensions/fotmob/CHANGELOG.md b/extensions/fotmob/CHANGELOG.md index 3b13f64bbae..6da926b5d0b 100644 --- a/extensions/fotmob/CHANGELOG.md +++ b/extensions/fotmob/CHANGELOG.md @@ -1,5 +1,10 @@ # Football Changelog +## [Fix] - 2024-12-20 + +- Fotmob API + - Match day has the same problem now as team details had before and solved it with the same solution + ## [Updates] - 2024-12-05 - Fotmob API diff --git a/extensions/fotmob/src/hooks/useMatchDay.ts b/extensions/fotmob/src/hooks/useMatchDay.ts index 4c7eaa0dfbb..638c0186283 100644 --- a/extensions/fotmob/src/hooks/useMatchDay.ts +++ b/extensions/fotmob/src/hooks/useMatchDay.ts @@ -1,13 +1,15 @@ import fetch from "cross-fetch"; import { useCachedPromise } from "@raycast/utils"; import type { MatchDayResponse } from "@/types/match-day"; +import { getHeaderToken } from "@/utils/token"; export function useMatchDay(date: Date) { const { data, error, isLoading } = useCachedPromise( async (date): Promise => { const dateStr = date.toISOString().split("T")[0].replace(/-/g, ""); const url = `https://www.fotmob.com/api/matches?date=${dateStr}`; - const searchResponse = await fetch(url); + const token = await getHeaderToken(); + const searchResponse = await fetch(url, { headers: token }); if (!searchResponse.ok) { throw new Error("Failed to fetch search results"); diff --git a/extensions/fotmob/src/hooks/useTeamDetail.ts b/extensions/fotmob/src/hooks/useTeamDetail.ts index 72b68da146e..66462f4be72 100644 --- a/extensions/fotmob/src/hooks/useTeamDetail.ts +++ b/extensions/fotmob/src/hooks/useTeamDetail.ts @@ -17,6 +17,7 @@ export function useTeamDetail(teamId: string) { async (teamId: string): Promise => { const url = `https://www.fotmob.com/api/teams?id=${teamId}`; const token = await getHeaderToken(); + const response = await fetch(url, { headers: token }); if (!response.ok) { throw new Error("Failed to fetch team details");