Skip to content

Commit 8f74eb6

Browse files
committed
fix: import axios dynamically
1 parent e2901af commit 8f74eb6

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

.changeset/violet-swans-reply.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"plantae": patch
3+
---
4+
5+
fix: import axios dynamically

packages/plantae/src/axios/utils.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { AxiosResponse } from "axios";
2-
import { AxiosError } from "axios";
32

43
// https://github.com/axios/axios/blob/7d45ab2e2ad6e59f5475e39afd4b286b1f393fc0/lib/core/settle.js#L15
54
export default function settle(
@@ -11,15 +10,17 @@ export default function settle(
1110
if (!response.status || !validateStatus || validateStatus(response.status)) {
1211
resolve(response);
1312
} else {
14-
reject(
15-
new AxiosError(
16-
"Request failed with status code " + response.status,
17-
[AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][
18-
Math.floor(response.status / 100) - 4
19-
],
20-
response.config,
21-
response.request,
22-
response
13+
import("axios").then(({ AxiosError }) =>
14+
reject(
15+
new AxiosError(
16+
"Request failed with status code " + response.status,
17+
[AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][
18+
Math.floor(response.status / 100) - 4
19+
],
20+
response.config,
21+
response.request,
22+
response
23+
)
2324
)
2425
);
2526
}

0 commit comments

Comments
 (0)