web-mikul-news/service/master-categories.tsx

48 lines
1.2 KiB
TypeScript

import {
httpDeleteInterceptor,
httpGet,
httpPost,
httpPut,
} from "./http-config/axios-base-service";
import Cookies from "js-cookie";
const token = Cookies.get("access_token");
export async function createCategory(data: any) {
const headers = {
"content-type": "application/json",
Authorization: `Bearer ${token}`,
};
const pathUrl = `/article-categories`;
return await httpPost(pathUrl, headers, data);
}
export async function updateCategory(id: string, data: any) {
const headers = {
"content-type": "application/json",
};
const pathUrl = `/article-categories/${id}`;
return await httpPut(pathUrl, headers, data);
}
export async function getCategoryById(id: number) {
const headers = {
"content-type": "application/json",
};
return await httpGet(`/article-categories/${id}`, headers);
}
export async function deleteCategory(id: number) {
const headers = {
"content-type": "application/json",
};
return await httpDeleteInterceptor(`article-categories/${id}`, headers);
}
export async function uploadCategoryThumbnail(id: string, data: any) {
const headers = {
"content-type": "multipart/form-data",
};
return await httpPost(`/article-categories/thumbnail/${id}`, headers, data);
}