From 7129fb0cc5b5346403933a0088e49d968ff43255 Mon Sep 17 00:00:00 2001 From: taohebin Date: Mon, 11 Mar 2024 15:11:51 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20request=E5=A2=9E=E5=8A=A0=20GET?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E6=90=BA=E5=B8=A6data=E7=9A=84=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/API/request/request.test.js | 8 +++++++- pages/API/request/request.uvue | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/pages/API/request/request.test.js b/pages/API/request/request.test.js index 2dd94105..9d772378 100644 --- a/pages/API/request/request.test.js +++ b/pages/API/request/request.test.js @@ -107,5 +107,11 @@ describe('ExtApi-Request', () => { await page.waitFor(2000); res = await page.data('jest_result'); expect(res).toBe(true) - }); + }); + it('Check Get With Data', async () => { + res = await page.callMethod('jest_get_with_data') + await page.waitFor(2000); + res = await page.data('jest_result'); + expect(res).toBe(true) + }) }); diff --git a/pages/API/request/request.uvue b/pages/API/request/request.uvue index bc33bda1..8890befd 100644 --- a/pages/API/request/request.uvue +++ b/pages/API/request/request.uvue @@ -300,6 +300,25 @@ this.jest_result = false; }, }); + }, + jest_get_with_data() { + uni.request({ + url: "https://unidemo.dcloud.net.cn/api/banner/36kr", + method: "GET", + data:{ + column: 'id,post_id,title,author_name,cover,published_at' //需要的字段名 + }, + timeout: 6000, + sslVerify: false, + withCredentials: false, + firstIpv4: false, + success: () => { + this.jest_result = true; + }, + fail: () => { + this.jest_result = false; + }, + }); }, } } -- GitLab