添加国家列表接口
This commit is contained in:
16
lib/api.ts
16
lib/api.ts
@@ -2,6 +2,7 @@ import { API_CONFIG, API_ENDPOINTS } from "@/constants/api";
|
||||
import {
|
||||
ApiListResponse,
|
||||
ApiResponse,
|
||||
Country,
|
||||
Match,
|
||||
MatchDetailData,
|
||||
Sport,
|
||||
@@ -32,6 +33,21 @@ export const fetchSports = async (): Promise<Sport[]> => {
|
||||
}
|
||||
};
|
||||
|
||||
export const fetchCountries = async (): Promise<Country[]> => {
|
||||
try {
|
||||
const response = await apiClient.get<ApiResponse<ApiListResponse<Country>>>(
|
||||
API_ENDPOINTS.COUNTRIES
|
||||
);
|
||||
if (response.data.code === 0) {
|
||||
return response.data.data.list;
|
||||
}
|
||||
throw new Error(response.data.message);
|
||||
} catch (error) {
|
||||
console.error("Fetch countries 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