File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed
packages/openapi-fetch/src Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -68,10 +68,13 @@ export default function createClient<Paths extends {}>(clientOptions: ClientOpti
68
68
69
69
// parse response (falling back to .text() when necessary)
70
70
if ( response . ok ) {
71
- let data : any = response . body ;
71
+ let data : any ; // we have to leave this empty here so that we don't consume the body
72
72
if ( parseAs !== "stream" ) {
73
73
const cloned = response . clone ( ) ;
74
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 ;
75
78
}
76
79
return { data, response : response as any } ;
77
80
}
You can’t perform that action at this time.
0 commit comments