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.
29 lines
616 B
TypeScript
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;
|
|
},
|
|
};
|