添加联赛列表接口
This commit is contained in:
25
lib/api.ts
25
lib/api.ts
@@ -3,6 +3,7 @@ import {
|
||||
ApiListResponse,
|
||||
ApiResponse,
|
||||
Country,
|
||||
League,
|
||||
Match,
|
||||
MatchDetailData,
|
||||
Sport,
|
||||
@@ -48,6 +49,30 @@ export const fetchCountries = async (): Promise<Country[]> => {
|
||||
}
|
||||
};
|
||||
|
||||
export const fetchLeagues = async (
|
||||
sportId: number,
|
||||
countryKey: string
|
||||
): Promise<League[]> => {
|
||||
try {
|
||||
const response = await apiClient.get<ApiResponse<ApiListResponse<League>>>(
|
||||
API_ENDPOINTS.LEAGUES,
|
||||
{
|
||||
params: {
|
||||
sportId,
|
||||
countryKey,
|
||||
},
|
||||
}
|
||||
);
|
||||
if (response.data.code === 0) {
|
||||
return response.data.data.list;
|
||||
}
|
||||
throw new Error(response.data.message);
|
||||
} catch (error) {
|
||||
console.error("Fetch leagues error:", error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
export const fetchTodayMatches = async (sportId: number): Promise<Match[]> => {
|
||||
try {
|
||||
const response = await apiClient.get<ApiResponse<ApiListResponse<Match>>>(
|
||||
|
||||
Reference in New Issue
Block a user