Skip to content

Commit 3da8a1c

Browse files
authored
fix(fetch/react-query-example) : use the correct response object in the middleware (#1731)
1 parent a9f529e commit 3da8a1c

File tree

1 file changed

+5
-5
lines changed
  • packages/openapi-fetch/examples/react-query/src/lib/api

1 file changed

+5
-5
lines changed

packages/openapi-fetch/examples/react-query/src/lib/api/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import createClient, { type Middleware } from "openapi-fetch";
22
import type { paths } from "./v1";
33

44
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();
5+
async onResponse({ response }) {
6+
if (response.status >= 400) {
7+
const body = response.headers.get("content-type")?.includes("json")
8+
? await response.clone().json()
9+
: await response.clone().text();
1010
throw new Error(body);
1111
}
1212
return undefined;

0 commit comments

Comments
 (0)