Skip to content

Commit

Permalink
🐛 FIX: Alias reqMeta.options to reqMeta.args (#391)
Browse files Browse the repository at this point in the history
Keep 'response' event compatibility
  • Loading branch information
fengmk2 committed Aug 23, 2022
1 parent df9506a commit e29fd00
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/HttpClient.ts
Expand Up @@ -489,7 +489,10 @@ export class HttpClient extends EventEmitter {
requestId,
error: null,
ctx: args.ctx,
req: reqMeta,
req: {
...reqMeta,
options: args,
},
res,
});
}
Expand Down
4 changes: 4 additions & 0 deletions test/HttpClient.events.test.ts
Expand Up @@ -35,6 +35,7 @@ describe('HttpClient.events.test.ts', () => {
responseCount++;
// console.log(info);
assert.equal(info.req.args.opaque.requestId, `mock-request-id-${requestCount}`);
assert.equal(info.req.options, info.req.args);
assert.equal(info.res.status, 200);
assert.equal(info.requestId, info.req.requestId);

Expand All @@ -55,6 +56,9 @@ describe('HttpClient.events.test.ts', () => {
});
assert.equal(response.status, 200);
assert.equal(response.data.method, 'GET');
assert.equal(requestCount, 1);
assert.equal(responseCount, 1);

response = await httpclient.request(_url, {
dataType: 'json',
opaque: {
Expand Down

0 comments on commit e29fd00

Please sign in to comment.