Skip to content

Commit

Permalink
馃悰 FIX: Typo on HttpClient request (#5097)
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed Dec 16, 2022
1 parent 1021faf commit 344139e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ declare module 'egg' {

// Compatible with both urllib@2 and urllib@3 RequestOptions to request
export interface EggHttpClient extends EventEmitter {
reques<T = any>(url: RequestURL): Promise<HttpClientResponse<T> | HttpClientResponseNext>;
request<T = any>(url: RequestURL): Promise<HttpClientResponse<T> | HttpClientResponseNext>;
request<T = any>(url: RequestURL, options: RequestOptions | RequestOptionsNext): Promise<HttpClientResponse<T> | HttpClientResponseNext>;
curl<T = any>(url: RequestURL): Promise<HttpClientResponse<T> | HttpClientResponseNext>;
curl<T = any>(url: RequestURL, options: RequestOptions | RequestOptionsNext): Promise<HttpClientResponse<T> | HttpClientResponseNext>;
Expand Down
10 changes: 10 additions & 0 deletions test/fixtures/apps/app-ts-type-check/normal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,27 @@ 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);
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();
Expand Down

0 comments on commit 344139e

Please sign in to comment.