satupeta-main/shared/services/topic.ts
2026-02-23 12:21:05 +07:00

27 lines
658 B
TypeScript
Executable File

import { ApiResponse } from "../types/api-response";
import { Topic } from "../types/topic";
import { apiHelpers } from "./api";
const topicApi = {
getTopics: async (): Promise<ApiResponse<Topic[]>> => {
return apiHelpers.get("/topik");
},
getTopicById: async (id: number): Promise<ApiResponse<Topic>> => {
return apiHelpers.get(`/topik/${id}`);
},
deleteTopic: async (id?: number): Promise<ApiResponse<null>> => {
return apiHelpers.delete(`/topik/${id}`);
},
createTopic: async (
topic: Omit<Topic, "id">
): Promise<ApiResponse<Topic>> => {
return apiHelpers.post("/topik", topic);
},
};
export default topicApi;