From dced6a92ea9456eac52e8fc6164b34c7a68d20be Mon Sep 17 00:00:00 2001 From: bac-joker Date: Tue, 6 Apr 2021 16:08:59 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20request=20dataField=20=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E8=A6=86=E7=9B=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/fes-plugin-request/src/template/setDataField.js | 8 ++++---- packages/fes-template-h5/src/pages/index.vue | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/fes-plugin-request/src/template/setDataField.js b/packages/fes-plugin-request/src/template/setDataField.js index 3cbb76d8..33ea2204 100644 --- a/packages/fes-plugin-request/src/template/setDataField.js +++ b/packages/fes-plugin-request/src/template/setDataField.js @@ -1,10 +1,10 @@ import { isObject } from './helpers'; export default async (ctx, next) => { - const { dataField, response } = ctx; - if (response && isObject(response.data) && dataField) { - ctx.response._rawData = response.data; - ctx.response.data = response.data[dataField]; + const dataField = ctx.config.dataField ?? ctx.dataField; + if (ctx.response && isObject(ctx.response.data) && dataField) { + ctx.response._rawData = ctx.response.data; + ctx.response.data = ctx.response.data[dataField]; } await next(); }; diff --git a/packages/fes-template-h5/src/pages/index.vue b/packages/fes-template-h5/src/pages/index.vue index 185c11bb..29e5530c 100644 --- a/packages/fes-template-h5/src/pages/index.vue +++ b/packages/fes-template-h5/src/pages/index.vue @@ -28,7 +28,9 @@ export default { const clickIcon = () => { console.log('click Icon'); }; - const { loading, data } = useRequest('/api'); + const { loading, data } = useRequest('/api', null, { + dataField: false + }); return { loading, data, From 40f4cef8c426e0f7884aebf26337be610702482b Mon Sep 17 00:00:00 2001 From: bac-joker Date: Tue, 6 Apr 2021 16:09:18 +0800 Subject: [PATCH 2/2] chore(release): publish --- lerna.json | 2 +- packages/fes-plugin-request/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lerna.json b/lerna.json index a8a675e2..e503a089 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.0.0-rc.12", + "version": "2.0.0-rc.13", "changelog": { "repo": "WeBankFinTech/fes.js", "cacheDir": ".changelog", diff --git a/packages/fes-plugin-request/package.json b/packages/fes-plugin-request/package.json index 59c8b6da..29029664 100644 --- a/packages/fes-plugin-request/package.json +++ b/packages/fes-plugin-request/package.json @@ -1,6 +1,6 @@ { "name": "@fesjs/plugin-request", - "version": "2.0.0-rc.11", + "version": "2.0.0-rc.13", "description": "@fesjs/plugin-request", "main": "lib/index.js", "files": [