mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2025-04-05 11:18:54 +08:00
fix: 修复 request 属性挂载问题
This commit is contained in:
parent
4169cc8c5f
commit
6649e0615b
@ -33,7 +33,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fesjs/utils": "^3.0.3",
|
"@fesjs/utils": "^3.0.3",
|
||||||
"@qlin/request": "^0.3.0"
|
"@qlin/request": "^0.3.1"
|
||||||
},
|
},
|
||||||
"typings": "./types.d.ts"
|
"typings": "./types.d.ts"
|
||||||
}
|
}
|
||||||
|
@ -15,16 +15,14 @@ function getRequestInstance() {
|
|||||||
return createRequest(defaultConfig);
|
return createRequest(defaultConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 不能立马初始化,用户配置可能还没准备好
|
||||||
let currentRequest;
|
let currentRequest;
|
||||||
|
|
||||||
export function rawRequest(url, data, options = {}) {
|
export function rawRequest(url, data, options = {}) {
|
||||||
if (typeof options === 'string') {
|
|
||||||
options = {
|
|
||||||
method: options,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (!currentRequest) {
|
if (!currentRequest) {
|
||||||
currentRequest = getRequestInstance();
|
currentRequest = getRequestInstance();
|
||||||
|
// 将 request 实例上的属性挂在到 rawRequest 上。
|
||||||
|
Object.assign(rawRequest, currentRequest);
|
||||||
}
|
}
|
||||||
return currentRequest(url, data, options);
|
return currentRequest(url, data, options);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user