submit
This commit is contained in:
parent
0377ab7775
commit
b2a0e35609
@ -21,12 +21,11 @@ type HttpMethod =
|
|||||||
| 'connect';
|
| 'connect';
|
||||||
interface RequestOptions {
|
interface RequestOptions {
|
||||||
baseUrl?: string;
|
baseUrl?: string;
|
||||||
dataType?: string;
|
|
||||||
url: string;
|
url: string;
|
||||||
data?: Record<string, any>;
|
data?: Record<string, any>;
|
||||||
method?: HttpMethod;
|
method?: HttpMethod;
|
||||||
header?: Record<string, string>;
|
header?: Record<string, string>;
|
||||||
params?: Record<string, any>; // 新增的参数字段
|
params?: Record<string, any>;
|
||||||
}
|
}
|
||||||
type RequestInterceptor = (config: RequestOptions) => RequestOptions;
|
type RequestInterceptor = (config: RequestOptions) => RequestOptions;
|
||||||
type ResponseInterceptor = (response: any) => any;
|
type ResponseInterceptor = (response: any) => any;
|
||||||
@ -62,7 +61,6 @@ class uniFetch {
|
|||||||
request(options: RequestOptions): Promise<any> {
|
request(options: RequestOptions): Promise<any> {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
options.baseUrl = options.baseUrl || this.baseUrl;
|
options.baseUrl = options.baseUrl || this.baseUrl;
|
||||||
options.dataType = options.dataType || "json";
|
|
||||||
options.url = options.baseUrl + options.url;
|
options.url = options.baseUrl + options.url;
|
||||||
options.data = options.data || {};
|
options.data = options.data || {};
|
||||||
options.method = options.method || "GET";
|
options.method = options.method || "GET";
|
||||||
@ -100,7 +98,6 @@ class uniFetch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private handleError(error: any): any {
|
private handleError(error: any): any {
|
||||||
// 在这里处理错误
|
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user