Skip to content

Commit

Permalink
Use validateStatus always true from axios
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomato6966 committed Oct 13, 2024
1 parent b554293 commit f403a4e
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 64 deletions.
15 changes: 3 additions & 12 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

15 changes: 3 additions & 12 deletions dist/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -62,24 +62,15 @@ var customFetch = /* @__PURE__ */ __name(async (input, options = {}) => {
url: url.toString(),
method: options?.method ?? "GET",
headers: options?.headers ?? {},
data: options?.body ?? void 0
data: options?.body ?? void 0,
validateStatus: /* @__PURE__ */ __name(() => true, "validateStatus")
}).then(
(r) => new CustomResponse(r.status === 204 ? null : r.data, {
status: r.status,
statusText: r.statusText,
headers: normalizeHeaders(r.headers)
})
).catch((error) => {
if (axios.isAxiosError(error) && error.response) {
const { status, statusText, headers, data } = error.response;
return new CustomResponse(data ?? null, {
status,
statusText,
headers: normalizeHeaders(headers)
});
}
throw error;
});
);
}, "customFetch");

// src/environment.ts
Expand Down
2 changes: 1 addition & 1 deletion dist/index.mjs.map

Large diffs are not rendered by default.

15 changes: 3 additions & 12 deletions dist/web.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/web.js.map

Large diffs are not rendered by default.

15 changes: 3 additions & 12 deletions dist/web.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,15 @@ var customFetch = /* @__PURE__ */ __name(async (input, options = {}) => {
url: url.toString(),
method: options?.method ?? "GET",
headers: options?.headers ?? {},
data: options?.body ?? void 0
data: options?.body ?? void 0,
validateStatus: /* @__PURE__ */ __name(() => true, "validateStatus")
}).then(
(r) => new CustomResponse(r.status === 204 ? null : r.data, {
status: r.status,
statusText: r.statusText,
headers: normalizeHeaders(r.headers)
})
).catch((error) => {
if (axios.isAxiosError(error) && error.response) {
const { status, statusText, headers, data } = error.response;
return new CustomResponse(data ?? null, {
status,
statusText,
headers: normalizeHeaders(headers)
});
}
throw error;
});
);
}, "customFetch");

// src/defaultFetch.ts
Expand Down
2 changes: 1 addition & 1 deletion dist/web.mjs.map

Large diffs are not rendered by default.

14 changes: 2 additions & 12 deletions src/customNodeFetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,13 @@ export const customFetch = async (input: RequestInfo | URL, options: RequestInit
method: options?.method ?? 'GET',
headers: options?.headers ?? {},
data: options?.body ?? undefined,
validateStatus: () => true,
} as AxiosRequestConfig).then(
(r) =>
new CustomResponse(r.status === 204 ? null : r.data, {
status: r.status,
statusText: r.statusText,
headers: normalizeHeaders(r.headers),
}) as unknown as ResponseLike,
).catch((error) => {
if (axios.isAxiosError(error) && error.response) {
const { status, statusText, headers, data } = error.response;

return new CustomResponse(data ?? null, {
status,
statusText,
headers: normalizeHeaders(headers),
}) as unknown as ResponseLike;
}
throw error;
});
);
};

0 comments on commit f403a4e

Please sign in to comment.