Skip to content

Commit 1c0fcfe

Browse files
committed
refactor: rename variables for clarity
1 parent c8e00ef commit 1c0fcfe

File tree

3 files changed

+35
-31
lines changed

3 files changed

+35
-31
lines changed

lib/build/axiosError.d.ts

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/build/axiosError.js

+17-15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/ts/axiosError.ts

+17-15
Original file line numberDiff line numberDiff line change
@@ -62,41 +62,43 @@ function enhanceAxiosError(
6262
return error;
6363
}
6464

65-
export async function createAxiosErrorFromFetchResp(response: Response): Promise<AxiosError> {
65+
export async function createAxiosErrorFromFetchResp(responseOrError: Response): Promise<AxiosError> {
6666
const config = {
67-
url: response.url,
68-
headers: response.headers
67+
url: responseOrError.url,
68+
headers: responseOrError.headers
6969
};
70-
const isProperResponse = "status" in response;
70+
const isResponse = "status" in responseOrError;
7171
let axiosResponse;
72-
if (isProperResponse) {
72+
if (isResponse) {
7373
let data;
74-
const contentType = response.headers.get("content-type");
74+
const contentType = responseOrError.headers.get("content-type");
7575
if (!contentType || contentType.includes("application/json")) {
7676
try {
77-
data = await response.json();
77+
data = await responseOrError.json();
7878
} catch {
79-
data = await response.text();
79+
data = await responseOrError.text();
8080
}
8181
} else if (contentType.includes("text/")) {
82-
data = await response.text();
82+
data = await responseOrError.text();
8383
} else {
84-
data = await response.blob();
84+
data = await responseOrError.blob();
8585
}
8686

8787
axiosResponse = {
8888
data,
89-
status: response.status,
90-
statusText: response.statusText,
91-
headers: response.headers,
89+
status: responseOrError.status,
90+
statusText: responseOrError.statusText,
91+
headers: responseOrError.headers,
9292
config: config,
9393
request: undefined
9494
};
9595
}
9696
return enhanceAxiosError(
97-
"status" in response ? new Error("Request failed with status code " + response.status) : response,
97+
"status" in responseOrError
98+
? new Error("Request failed with status code " + responseOrError.status)
99+
: responseOrError,
98100
config,
99-
(response as any).code,
101+
(responseOrError as any).code,
100102
undefined,
101103
axiosResponse
102104
);

0 commit comments

Comments
 (0)