Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/hooks/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export class SDKHooks implements Hooks {
): Promise<Request> {
let req = request;

for (const hook of this.beforeRequestHooks) {
for await (const hook of this.beforeRequestHooks) {
req = await hook.beforeRequest(hookCtx, req);
}

Expand All @@ -106,7 +106,7 @@ export class SDKHooks implements Hooks {
): Promise<Response> {
let res = response;

for (const hook of this.afterSuccessHooks) {
for await (const hook of this.afterSuccessHooks) {
res = await hook.afterSuccess(hookCtx, res);
}

Expand All @@ -121,7 +121,7 @@ export class SDKHooks implements Hooks {
let res = response;
let err = error;

for (const hook of this.afterErrorHooks) {
for await (const hook of this.afterErrorHooks) {
const result = await hook.afterError(hookCtx, res, err);
res = result.response;
err = result.error;
Expand Down
6 changes: 3 additions & 3 deletions src/lib/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class HTTPClient {

async request(request: Request): Promise<Response> {
let req = request;
for (const hook of this.requestHooks) {
for await (const hook of this.requestHooks) {
const nextRequest = await hook(req);
if (nextRequest) {
req = nextRequest;
Expand All @@ -62,13 +62,13 @@ export class HTTPClient {
try {
const res = await this.fetcher(req);

for (const hook of this.responseHooks) {
for await (const hook of this.responseHooks) {
await hook(res, req);
}

return res;
} catch (err) {
for (const hook of this.requestErrorHooks) {
for await (const hook of this.requestErrorHooks) {
await hook(err, req);
}

Expand Down