Skip to content

Commit cd127a9

Browse files
authored
Fix fetch client response parsing without re-reading body (#1416)
Signed-off-by: Sora Morimoto <[email protected]>
1 parent 9a7c788 commit cd127a9

File tree

30 files changed

+235
-115
lines changed

30 files changed

+235
-115
lines changed

.changeset/soft-guests-repair.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"swagger-typescript-api": patch
3+
---
4+
5+
Fix fetch client response parsing without re-reading body.

templates/base/http-clients/fetch-http-client.ejs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,8 @@ export class HttpClient<SecurityDataType = unknown> {
200200
r.data = (null as unknown) as T;
201201
r.error = (null as unknown) as E;
202202

203-
const data = !responseFormat ? r : await response[responseFormat]()
203+
const responseToParse = responseFormat ? response.clone() : response;
204+
const data = !responseFormat ? r : await responseToParse[responseFormat]()
204205
.then((data) => {
205206
if (r.ok) {
206207
r.data = data;

0 commit comments

Comments
 (0)