From f83dee6c0ef651e5399b4487e74084f01d3918f2 Mon Sep 17 00:00:00 2001 From: Jiayu Liu Date: Fri, 6 Jul 2018 01:07:52 +0800 Subject: [PATCH] [wepy] modifying wx.request params (#27049) * [wepy] modifying wx.request params * updating code owners --- .github/CODEOWNERS | 2 ++ types/wepy/wepy-tests.ts | 11 ++++++++++- types/wepy/wx_enhanced.d.ts | 18 +++++++++++++++++- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 247c8ab6a4..fb6f7ba030 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -4374,6 +4374,8 @@ /types/weighted/ @ccitro /types/weixin-app/ @taoqf @AlexStacker /types/wellknown/ @yairtawil +/types/wepy/ @Jimexist +/types/wepy-redux/ @Jimexist /types/whatwg-mimetype/ @petejohanson /types/whatwg-streams/ @saschanaz @ksm2 /types/whatwg-url/ @aomarks diff --git a/types/wepy/wepy-tests.ts b/types/wepy/wepy-tests.ts index 071eda0d9e..c0fb4b3d89 100644 --- a/types/wepy/wepy-tests.ts +++ b/types/wepy/wepy-tests.ts @@ -21,8 +21,17 @@ export class MyComponent extends wepy.component { methods = {}; - onLoad() { + async onLoad() { super.onLoad(); + await wepy.request("http://www.weixin.com"); + const a = await wepy.request({ + url: "www.weixin.com", + data: { a: 1, b: 2 }, + header: { + "content-type": "application/json" + }, + method: "POST" + }); } } diff --git a/types/wepy/wx_enhanced.d.ts b/types/wepy/wx_enhanced.d.ts index d5e66dea34..5769c4f718 100644 --- a/types/wepy/wx_enhanced.d.ts +++ b/types/wepy/wx_enhanced.d.ts @@ -114,6 +114,22 @@ export interface UrlParam { url: string; } +export interface RequestParam extends UrlParam { + data?: object | string | ArrayBuffer; + header?: object; + method?: + | "GET" + | "OPTIONS" + | "HEAD" + | "POST" + | "PUT" + | "DELETE" + | "TRACE" + | "CONNECT"; + dataType?: "json" | "text"; + responseType?: "text" | "arraybuffer"; +} + export interface FilePathParam { filePath: string; } @@ -332,7 +348,7 @@ export interface WxEnhances { removeStorage(params: { key: string }): Promise; - request(params: UrlParam): Promise; + request(params: RequestParam | string): Promise; requestPayment(params: { timeStamp: string;