57 lines
1.5 KiB
TypeScript
57 lines
1.5 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",
|
|
Authorization: `Bearer ${token}`,
|
|
};
|
|
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 deleteCategory(id: number) {
|
|
const headers = {
|
|
"content-type": "application/json",
|
|
Authorization: `Bearer ${token}`,
|
|
};
|
|
return await httpDeleteInterceptor(`article-categories/${id}`, headers);
|
|
}
|
|
|
|
export async function uploadCategoryThumbnail(id: string, data: any) {
|
|
const headers = {
|
|
"content-type": "multipart/form-data",
|
|
Authorization: `Bearer ${token}`,
|
|
};
|
|
return await httpPost(`/article-categories/thumbnail/${id}`, headers, data);
|
|
}
|