File tree 1 file changed +7
-2
lines changed
packages/openapi-fetch/src
1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -83,16 +83,21 @@ export default function createClient<Paths extends {}>(clientOptions: ClientOpti
83
83
}
84
84
85
85
// fetch!
86
- const response = await fetch ( finalURL , {
86
+ const originalResponse = await fetch ( finalURL , {
87
87
redirect : "follow" ,
88
88
...options ,
89
89
...init ,
90
90
headers : baseHeaders ,
91
91
body : typeof requestBody === "string" ? requestBody : JSON . stringify ( requestBody ) ,
92
92
} ) ;
93
93
94
+ const response = originalResponse . clone ( ) ;
95
+
94
96
// don’t parse JSON if status is 204, or Content-Length is '0'
95
- const body = response . status === 204 || response . headers . get ( "Content-Length" ) === "0" ? { } : await response . json ( ) ;
97
+ const body = originalResponse . status === 204 || originalResponse . headers . get ( "Content-Length" ) === "0"
98
+ ? { }
99
+ : await originalResponse . json ( ) ;
100
+
96
101
return response . ok ? { data : body , response } : { error : body , response : response } ;
97
102
}
98
103
You can’t perform that action at this time.
0 commit comments