diff --git a/packages/fes-plugin-request/package.json b/packages/fes-plugin-request/package.json index 79f8c401..a4dc4e0c 100644 --- a/packages/fes-plugin-request/package.json +++ b/packages/fes-plugin-request/package.json @@ -33,7 +33,7 @@ }, "dependencies": { "@fesjs/utils": "^3.0.3", - "@qlin/request": "^0.3.0" + "@qlin/request": "^0.3.1" }, "typings": "./types.d.ts" } diff --git a/packages/fes-plugin-request/src/template/request.js b/packages/fes-plugin-request/src/template/request.js index 88cebb4f..cebde7ee 100644 --- a/packages/fes-plugin-request/src/template/request.js +++ b/packages/fes-plugin-request/src/template/request.js @@ -15,16 +15,14 @@ function getRequestInstance() { return createRequest(defaultConfig); } +// 不能立马初始化,用户配置可能还没准备好 let currentRequest; export function rawRequest(url, data, options = {}) { - if (typeof options === 'string') { - options = { - method: options, - }; - } if (!currentRequest) { currentRequest = getRequestInstance(); + // 将 request 实例上的属性挂在到 rawRequest 上。 + Object.assign(rawRequest, currentRequest); } return currentRequest(url, data, options); }