add login
This commit is contained in:
1 parent
1ac9441a4d
commit
89e65f373f
19 files changed
+183
-28
No files matched your search
@@ -0,0 +1,29 @@
|
||||
import { AxiosResponse } from 'axios';
|
||||
import httpClient from '../../instance';
|
||||
import { IArticle, IArticleDetailResponse, IArticleListResponse } from './types';
|
||||
|
||||
class ArticleService {
|
||||
key = 'articles';
|
||||
|
||||
async getAll(): Promise<AxiosResponse<IArticleListResponse>> {
|
||||
return await httpClient.get(`/${this.key}`);
|
||||
}
|
||||
|
||||
async get(id: string | string[]): Promise<AxiosResponse<IArticleDetailResponse>> {
|
||||
return httpClient.get(`/${this.key}/${id}`);
|
||||
}
|
||||
|
||||
async create(data: IArticle): Promise<AxiosResponse<IArticleDetailResponse>> {
|
||||
return httpClient.post(`/${this.key}`, data);
|
||||
}
|
||||
|
||||
async update(id: string | string[], data: IArticle): Promise<AxiosResponse<IArticleDetailResponse>> {
|
||||
return httpClient.put(`/${this.key}/${id}`, data);
|
||||
}
|
||||
|
||||
async delete(id: string | string[]): Promise<AxiosResponse<null>> {
|
||||
return httpClient.delete(`/${this.key}/${id}`);
|
||||
}
|
||||
}
|
||||
|
||||
export default new ArticleService();
|
||||
Reference in new issue
Block a user