add abort
This commit is contained in:
1 parent
3ea9f786dc
commit
8b488de9d6
7 files changed
+107
-31
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { AxiosResponse } from 'axios';
|
||||
import { AxiosRequestConfig, AxiosResponse } from 'axios';
|
||||
import { httpClient } from '../instance';
|
||||
import { IDocument, IDocumentDetailResponse, IDocumentListResponse } from './models';
|
||||
|
||||
@@ -12,26 +12,32 @@ export interface IDocumentQuery {
|
||||
class DocumentOperator {
|
||||
key = 'documents';
|
||||
|
||||
async getAll(query: IDocumentQuery): Promise<AxiosResponse<IDocumentListResponse>> {
|
||||
async getAll(query: IDocumentQuery, config?: AxiosRequestConfig): Promise<AxiosResponse<IDocumentListResponse>> {
|
||||
return await httpClient.get(`/${this.key}/`, {
|
||||
...config,
|
||||
params: query
|
||||
});
|
||||
}
|
||||
|
||||
async get(id: string): Promise<AxiosResponse<IDocumentDetailResponse>> {
|
||||
return await httpClient.get(`/${this.key}/${id}`);
|
||||
async get(id: string, config?: AxiosRequestConfig): Promise<AxiosResponse<IDocumentDetailResponse>> {
|
||||
console.log('sss', config);
|
||||
return await httpClient.get(`/${this.key}/${id}`, config);
|
||||
}
|
||||
|
||||
async create(data: IDocument): Promise<AxiosResponse<IDocumentDetailResponse>> {
|
||||
return await httpClient.post(`/${this.key}/`, data);
|
||||
async create(data: IDocument, config?: AxiosRequestConfig): Promise<AxiosResponse<IDocumentDetailResponse>> {
|
||||
return await httpClient.post(`/${this.key}/`, data, config);
|
||||
}
|
||||
|
||||
async update(id: string, data: IDocument): Promise<AxiosResponse<IDocumentDetailResponse>> {
|
||||
return await httpClient.put(`/${this.key}/${id}`, data);
|
||||
async update(
|
||||
id: string,
|
||||
data: IDocument,
|
||||
config?: AxiosRequestConfig
|
||||
): Promise<AxiosResponse<IDocumentDetailResponse>> {
|
||||
return await httpClient.put(`/${this.key}/${id}`, data, config);
|
||||
}
|
||||
|
||||
async delete(id: string): Promise<AxiosResponse<null>> {
|
||||
return await httpClient.delete(`/${this.key}/${id}`);
|
||||
async delete(id: string, config?: AxiosRequestConfig): Promise<AxiosResponse<null>> {
|
||||
return await httpClient.delete(`/${this.key}/${id}`, config);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user