Skip to content

Commit

Permalink
Update fotmob extension (#15959)
Browse files Browse the repository at this point in the history
* fix fetching matchDay

* Update CHANGELOG.md and optimise images

---------

Co-authored-by: raycastbot <bot@raycast.com>
  • Loading branch information
Antitoxic9639 and raycastbot authored Dec 20, 2024
1 parent 96064c6 commit 34e6d5c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions extensions/fotmob/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 3 additions & 1 deletion extensions/fotmob/src/hooks/useMatchDay.ts
Original file line number Diff line number Diff line change
@@ -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<MatchDayResponse> => {
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");
Expand Down
1 change: 1 addition & 0 deletions extensions/fotmob/src/hooks/useTeamDetail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export function useTeamDetail(teamId: string) {
async (teamId: string): Promise<TeamDetailData> => {
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");
Expand Down

0 comments on commit 34e6d5c

Please sign in to comment.