Skip to content

Commit 29fc4dc

Browse files
committed
Skip formatting if FormData input is provided
1 parent 325e308 commit 29fc4dc

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Diff for: templates/base/http-clients/fetch-http-client.ejs

+8-3
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,12 @@ export class HttpClient<SecurityDataType = unknown> {
104104
private contentFormatters: Record<ContentType, (input: any) => any> = {
105105
[ContentType.Json]: (input:any) => input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
106106
[ContentType.Text]: (input:any) => input !== null && typeof input !== "string" ? JSON.stringify(input) : input,
107-
[ContentType.FormData]: (input: any) =>
108-
Object.keys(input || {}).reduce((formData, key) => {
107+
[ContentType.FormData]: (input: any) => {
108+
if (input instanceof FormData) {
109+
return input;
110+
}
111+
112+
return Object.keys(input || {}).reduce((formData, key) => {
109113
const property = input[key];
110114
formData.append(
111115
key,
@@ -116,7 +120,8 @@ export class HttpClient<SecurityDataType = unknown> {
116120
`${property}`
117121
);
118122
return formData;
119-
}, new FormData()),
123+
}, new FormData());
124+
}
120125
[ContentType.UrlEncoded]: (input: any) => this.toQueryString(input),
121126
}
122127

0 commit comments

Comments
 (0)