From 344139e4759f56ab2beca2e2a5c2783160396ba9 Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Fri, 16 Dec 2022 15:07:48 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20FIX:=20Typo=20on=20HttpClient=20?= =?UTF-8?q?request=20(#5097)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.d.ts | 2 +- test/fixtures/apps/app-ts-type-check/normal.ts | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 16d6557588..b27ee9fa31 100644 --- a/index.d.ts +++ b/index.d.ts @@ -50,7 +50,7 @@ declare module 'egg' { // Compatible with both urllib@2 and urllib@3 RequestOptions to request export interface EggHttpClient extends EventEmitter { - reques(url: RequestURL): Promise | HttpClientResponseNext>; + request(url: RequestURL): Promise | HttpClientResponseNext>; request(url: RequestURL, options: RequestOptions | RequestOptionsNext): Promise | HttpClientResponseNext>; curl(url: RequestURL): Promise | HttpClientResponseNext>; curl(url: RequestURL, options: RequestOptions | RequestOptionsNext): Promise | HttpClientResponseNext>; diff --git a/test/fixtures/apps/app-ts-type-check/normal.ts b/test/fixtures/apps/app-ts-type-check/normal.ts index 6021ceaf68..d0ccbb9c08 100644 --- a/test/fixtures/apps/app-ts-type-check/normal.ts +++ b/test/fixtures/apps/app-ts-type-check/normal.ts @@ -41,9 +41,12 @@ app.inspect(); app.listen(1002); app.logger.info(app.locals.test); const ctxHttpClient = new app.ContextHttpClient({} as Context); +ctxHttpClient.request('http://127.0.0.1'); ctxHttpClient.request('http://127.0.0.1', { method: 'GET' }); const appHttpClient = new app.HttpClient(app); +appHttpClient.request('http://127.0.0.1'); appHttpClient.request('http://127.0.0.1', { method: 'GET' }); +app.httpclient.request('http://127.0.0.1').catch(() => {}); app.httpclient.request('http://127.0.0.1', { method: 'GET' }).catch(() => {}); app.logger.info(app.Service); app.logger.info(app.Controller); @@ -51,7 +54,14 @@ app.controller.test().then(() => {}); async function main() { await app.runInAnonymousContextScope(async ctx => { + await ctx.httpclient.request('url', {}); await ctx.httpclient.request('url'); + await ctx.httpclient.curl('url', {}); + await ctx.httpclient.curl('url'); + await app.httpclient.request('url', {}); + await app.httpclient.request('url'); + await app.httpclient.curl('url', {}); + await app.httpclient.curl('url'); }); } main();