We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a9f529e commit 3da8a1cCopy full SHA for 3da8a1c
packages/openapi-fetch/examples/react-query/src/lib/api/index.ts
@@ -2,11 +2,11 @@ import createClient, { type Middleware } from "openapi-fetch";
2
import type { paths } from "./v1";
3
4
const throwOnError: Middleware = {
5
- async onResponse(res) {
6
- if (res.status >= 400) {
7
- const body = res.headers.get("content-type")?.includes("json")
8
- ? await res.clone().json()
9
- : await res.clone().text();
+ async onResponse({ response }) {
+ if (response.status >= 400) {
+ const body = response.headers.get("content-type")?.includes("json")
+ ? await response.clone().json()
+ : await response.clone().text();
10
throw new Error(body);
11
}
12
return undefined;
0 commit comments