We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1f3fefa commit 27969edCopy full SHA for 27969ed
packages/openapi-fetch/src/index.ts
@@ -68,10 +68,13 @@ export default function createClient<Paths extends {}>(clientOptions: ClientOpti
68
69
// parse response (falling back to .text() when necessary)
70
if (response.ok) {
71
- let data: any = response.body;
+ let data: any; // we have to leave this empty here so that we don't consume the body
72
if (parseAs !== "stream") {
73
const cloned = response.clone();
74
data = typeof cloned[parseAs] === "function" ? await cloned[parseAs]() : await cloned.text();
75
+ } else {
76
+ // bun consumes the body when calling response.body, therefore we need to clone the response before accessing it
77
+ data = response.clone().body;
78
}
79
return { data, response: response as any };
80
0 commit comments