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:
@@ -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;
|
||||
},
|
||||
};
|
||||
|
||||
16
frontend/src/services/tag.service.ts
Normal file
16
frontend/src/services/tag.service.ts
Normal 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;
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user