Skip to content

Commit f1141be

Browse files
committed
temp
1 parent 9b0da59 commit f1141be

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

packages/plantae/src/axios/createAxiosInterceptors.spec.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,4 +584,29 @@ describe("createAxiosInterceptors", () => {
584584
"Request failed with status code 500",
585585
);
586586
});
587+
588+
it("should throw error if status code validation failed", async () => {
589+
server.use(
590+
http.get(base("/"), () => {
591+
return new Response(null, {
592+
status: 500,
593+
});
594+
}),
595+
);
596+
597+
const axios = Axios.create({
598+
baseURL,
599+
});
600+
601+
const { request, response } = createAxiosInterceptors({
602+
plugins: [],
603+
});
604+
605+
axios.interceptors.request.use(request.onFulfilled, request.onRejected);
606+
axios.interceptors.response.use(response.onFulfilled, response.onRejected);
607+
608+
await expect(axios.get("/")).rejects.toThrow(
609+
"Request failed with status code 500",
610+
);
611+
});
587612
});

packages/plantae/src/axios/createAxiosInterceptors.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import type {
55
InternalAxiosRequestConfig,
66
} from "axios";
77

8+
import Axios from "axios";
9+
810
import createMiddleware from "../createMiddleware";
911
import type { AdapterRequest, AdapterResponse, Plugin } from "../types";
1012
import { isArrayBuffer, isNullBodyStatus } from "../utils";
@@ -116,8 +118,6 @@ async function extendClientRequest(
116118
clientRequest.signal = adapterRequest.signal;
117119
clientRequest.withCredentials = adapterRequest.credentials === "include";
118120

119-
clientRequest.validateStatus = null;
120-
121121
return clientRequest;
122122
}
123123

@@ -193,10 +193,10 @@ async function extendClientResponse(
193193
}
194194

195195
const createAxiosInterceptors = ({
196-
client,
196+
client = Axios.create(),
197197
plugins,
198198
}: {
199-
client: AxiosInstance;
199+
client?: AxiosInstance;
200200
plugins?: Plugin[];
201201
}): {
202202
request: Interceptor<"request">;

0 commit comments

Comments
 (0)