Match-id-55b5f86a1f1d697eedbd6697fbb22779a206ecf5

This commit is contained in:
* 2023-09-06 15:46:46 +08:00
parent 54eb3df4f8
commit 693940c021
3 changed files with 15 additions and 2 deletions

View File

@ -7,5 +7,5 @@
"env": {
"NODE_ENV": "development"
},
"ext": "js,json"
"ext": "js,mjs,json"
}

View File

@ -29,6 +29,16 @@ class InulaRequest implements IrInterface {
response: new InterceptorManager(),
};
this.processRequest = processRequest;
// 支持动态传递请求方法保证 this 指向正确
this.request = this.request.bind(this);
this.get = this.get.bind(this);
this.delete = this.delete.bind(this);
this.head = this.head.bind(this);
this.options = this.options.bind(this);
this.post = this.post.bind(this);
this.put = this.put.bind(this);
this.patch = this.patch.bind(this);
}
request<T = unknown>(requestParam: string | Record<string, any>, config?: IrRequestConfig): Promise<IrResponse<T>> {

View File

@ -21,10 +21,13 @@ export const fetchRequest = (config: IrRequestConfig): Promise<IrResponse> => {
withCredentials = false,
onUploadProgress = null,
onDownloadProgress = null,
signal,
} = config;
let controller = new AbortController();
let signal = controller.signal;
if (!signal) {
signal = controller.signal;
}
// 处理请求取消
if (cancelToken) {