init
This commit is contained in:
25
src/services/categoryService.ts
Normal file
25
src/services/categoryService.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
// src/services/categoryService.ts
|
||||
import apiClient from '@/plugins/axios';
|
||||
import {Category} from "@/models/Category"; // Импортируете настроенный экземпляр axios
|
||||
|
||||
export const getCategories = async (type = null) => {
|
||||
|
||||
type = type ? type : ''
|
||||
return await apiClient.get('/categories/?type=' + type);
|
||||
};
|
||||
|
||||
export const getCategoryTypes = async () => {
|
||||
return await apiClient.get('/categories/types/');
|
||||
}
|
||||
|
||||
export const createCategory = async (category: Category) => {
|
||||
return await apiClient.post('/categories', category);
|
||||
};
|
||||
|
||||
export const updateCategory = async (id: number, category: any) => {
|
||||
return await apiClient.put(`/categories/${id}`, category);
|
||||
};
|
||||
|
||||
export const deleteCategory = async (id: number) => {
|
||||
return await apiClient.delete(`/categories/${id}`);
|
||||
};
|
||||
Reference in New Issue
Block a user