Skip to content

Commit

Permalink
Fix for TS 4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
cblanc committed Oct 4, 2021
1 parent f78ea2e commit 4b8a33f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const toParam = (key: string, value: string): string =>
export const parseQuery = (query: StringMap): string => {
const keys = Object.keys(query);
if (keys.length === 0) return "";
return "?" + keys.map(key => toParam(key, query[key])).join("&");
return "?" + keys.map((key) => toParam(key, query[key])).join("&");
};

/**
Expand Down Expand Up @@ -116,18 +116,20 @@ export class Agent implements IAgent {
try {
if (body !== undefined) requestInit.body = JSON.stringify(body);
} catch (error) {
return handleError(error);
return handleError(error as Error);
}

const uri = `${url}${parseQuery(query)}`;

let response: Response;
return timedFetch(uri, requestInit, timeout, abortController)
.then(r => {
.then((r) => {
response = r;
return r.json();
})
.then(responseBody => toHttpResponse(httpRequest, response, responseBody))
.then((responseBody) =>
toHttpResponse(httpRequest, response, responseBody)
)
.catch(handleError);
}
}

0 comments on commit 4b8a33f

Please sign in to comment.