Files
memegoat/frontend/src/services/favorite.service.ts
Mathis HERRIOT c6b23de481 feat(api): add TagService and enhance API error handling
Introduce `TagService` to manage tag-related API interactions. Add SSR cookie interceptor for API requests and implement token refresh logic on 401 errors. Update `FavoriteService` to use `favoritesOnly` filter for exploring content.
2026-01-14 22:19:11 +01:00

29 lines
616 B
TypeScript

import api from "@/lib/api";
import type { Content, PaginatedResponse } from "@/types/content";
export const FavoriteService = {
async add(contentId: string): Promise<void> {
await api.post(`/favorites/${contentId}`);
},
async remove(contentId: string): Promise<void> {
await api.delete(`/favorites/${contentId}`);
},
async list(params: {
limit: number;
offset: number;
}): Promise<PaginatedResponse<Content>> {
const { data } = await api.get<PaginatedResponse<Content>>(
"/contents/explore",
{
params: {
...params,
favoritesOnly: true,
},
},
);
return data;
},
};