添加即将到来比赛列表接口
This commit is contained in:
30
lib/api.ts
30
lib/api.ts
@@ -7,6 +7,7 @@ import {
|
||||
Match,
|
||||
MatchDetailData,
|
||||
Sport,
|
||||
UpcomingMatch,
|
||||
} from "@/types/api";
|
||||
import axios from "axios";
|
||||
|
||||
@@ -108,3 +109,32 @@ export const fetchMatchDetail = async (
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
export const fetchUpcomingMatches = async (
|
||||
sportId: number,
|
||||
leagueKey: string,
|
||||
limit: number = 50
|
||||
): Promise<UpcomingMatch[]> => {
|
||||
try {
|
||||
const response =
|
||||
await apiClient.get<ApiResponse<ApiListResponse<UpcomingMatch>>>(
|
||||
API_ENDPOINTS.UPCOMING_MATCHES,
|
||||
{
|
||||
params: {
|
||||
sport_id: sportId,
|
||||
leagueKey,
|
||||
limit,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
if (response.data.code === 0) {
|
||||
return response.data.data.list;
|
||||
}
|
||||
|
||||
throw new Error(response.data.message);
|
||||
} catch (error) {
|
||||
console.error("Fetch upcoming matches error:", error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user