File tree 1 file changed +8
-3
lines changed
templates/base/http-clients
1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -104,8 +104,12 @@ export class HttpClient<SecurityDataType = unknown> {
104
104
private contentFormatters: Record<ContentType , (input: any) => any> = {
105
105
[ContentType.Json]: (input:any) => input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
106
106
[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) => {
109
113
const property = input[key];
110
114
formData.append(
111
115
key,
@@ -116,7 +120,8 @@ export class HttpClient<SecurityDataType = unknown> {
116
120
`${property}`
117
121
);
118
122
return formData;
119
- }, new FormData()),
123
+ }, new FormData());
124
+ }
120
125
[ContentType.UrlEncoded]: (input: any) => this.toQueryString(input),
121
126
}
122
127
You can’t perform that action at this time.
0 commit comments