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.
This commit is contained in:
Mathis HERRIOT
2026-01-14 22:19:11 +01:00
parent 0611ef715c
commit c6b23de481
3 changed files with 65 additions and 5 deletions

View File

@@ -14,9 +14,15 @@ export const FavoriteService = {
limit: number;
offset: number;
}): Promise<PaginatedResponse<Content>> {
const { data } = await api.get<PaginatedResponse<Content>>("/favorites", {
params,
});
const { data } = await api.get<PaginatedResponse<Content>>(
"/contents/explore",
{
params: {
...params,
favoritesOnly: true,
},
},
);
return data;
},
};

View File

@@ -0,0 +1,16 @@
import api from "@/lib/api";
import type { Tag } from "@/types/content";
export const TagService = {
async getAll(
params: {
limit?: number;
offset?: number;
query?: string;
sort?: "popular" | "recent";
} = {},
): Promise<Tag[]> {
const { data } = await api.get<Tag[]>("/tags", { params });
return data;
},
};