Files
memegoat/frontend/src/services/category.service.ts
Mathis HERRIOT c8820a71b6 feat(categories): add create, update, and delete methods to category service
- Introduced `create`, `update`, and `remove` methods for managing categories via the service.
- Enables API integration for category CRUD functionality.
2026-01-21 13:20:16 +01:00

29 lines
782 B
TypeScript

import api from "@/lib/api";
import type { Category } from "@/types/content";
export const CategoryService = {
async getAll(): Promise<Category[]> {
const { data } = await api.get<Category[]>("/categories");
return data;
},
async getOne(id: string): Promise<Category> {
const { data } = await api.get<Category>(`/categories/${id}`);
return data;
},
async create(category: Partial<Category>): Promise<Category> {
const { data } = await api.post<Category>("/categories", category);
return data;
},
async update(id: string, category: Partial<Category>): Promise<Category> {
const { data } = await api.patch<Category>(`/categories/${id}`, category);
return data;
},
async remove(id: string): Promise<void> {
await api.delete(`/categories/${id}`);
},
};