Skip to content

Commit 6923be5

Browse files
frazarsmorimoto
authored andcommitted
Skip formatting if FormData input is provided
1 parent c604d1f commit 6923be5

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,12 @@ export class HttpClient<SecurityDataType = unknown> {
106106
[ContentType.Json]: (input:any) => input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
107107
[ContentType.JsonApi]: (input:any) => input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
108108
[ContentType.Text]: (input:any) => input !== null && typeof input !== "string" ? JSON.stringify(input) : input,
109-
[ContentType.FormData]: (input: any) =>
110-
Object.keys(input || {}).reduce((formData, key) => {
109+
[ContentType.FormData]: (input: any) => {
110+
if (input instanceof FormData) {
111+
return input;
112+
}
113+
114+
return Object.keys(input || {}).reduce((formData, key) => {
111115
const property = input[key];
112116
formData.append(
113117
key,
@@ -118,7 +122,8 @@ export class HttpClient<SecurityDataType = unknown> {
118122
`${property}`
119123
);
120124
return formData;
121-
}, new FormData()),
125+
}, new FormData());
126+
},
122127
[ContentType.UrlEncoded]: (input: any) => this.toQueryString(input),
123128
}
124129

0 commit comments

Comments
 (0)