实现收藏页面
This commit is contained in:
23
lib/api.ts
23
lib/api.ts
@@ -6,6 +6,7 @@ import {
|
||||
AppleSignInResponse,
|
||||
Country,
|
||||
FavoriteCheckResponse,
|
||||
FavoriteListResponse,
|
||||
FavoriteRequest,
|
||||
H2HData,
|
||||
League,
|
||||
@@ -483,3 +484,25 @@ export const checkFavorite = async (
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
export const fetchFavorites = async (
|
||||
type: string,
|
||||
page: number = 1,
|
||||
pageSize: number = 20
|
||||
): Promise<FavoriteListResponse> => {
|
||||
try {
|
||||
const response = await apiClient.get<ApiResponse<FavoriteListResponse>>(
|
||||
API_ENDPOINTS.FAVORITES,
|
||||
{
|
||||
params: { type, page, pageSize },
|
||||
}
|
||||
);
|
||||
if (response.data.code === 0) {
|
||||
return response.data.data;
|
||||
}
|
||||
throw new Error(response.data.message);
|
||||
} catch (error) {
|
||||
console.error("Fetch favorites error:", error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user