1
1
mirror of https://github.com/aelve/guide.git synced 2024-12-26 06:11:33 +03:00
guide/front/client/service/Category.ts

38 lines
746 B
TypeScript
Raw Normal View History

2018-09-12 23:09:34 +03:00
import axios from "axios";
class CategoryService {
async getCategoryList(): Promise<ICategory[]> {
const { data } = await axios.get("api/categories", {})
return data
}
2018-09-16 21:02:30 +03:00
async createCategory({ title }: ICategory): Promise<ICategory[]> {
const { data } = await axios.post('api/category', null, {
params: {
title
}
})
return data
}
2018-09-12 23:09:34 +03:00
}
2018-09-16 16:32:35 +03:00
export enum CategoryStatus {
finished = 'CategoryFinished',
inProgress = 'CategoryWIP',
toBeWritten = 'CategoryStub'
}
2018-09-12 23:09:34 +03:00
export interface ICategory {
2018-09-16 21:02:30 +03:00
created?: string
group?: string
status?: CategoryStatus
title?: string
uid?: string
2018-09-12 23:09:34 +03:00
}
2018-09-16 16:32:35 +03:00
2018-09-12 23:09:34 +03:00
const categoryServiceInstance = new CategoryService()
export { categoryServiceInstance as CategoryService }