File tree 1 file changed +20
-8
lines changed
templates/base/http-clients
1 file changed +20
-8
lines changed Original file line number Diff line number Diff line change @@ -106,16 +106,28 @@ export class HttpClient<SecurityDataType = unknown> {
106
106
[ContentType.Text]: (input:any) => input !== null && typeof input !== "string" ? JSON.stringify(input) : input,
107
107
[ContentType.FormData]: (input: any) =>
108
108
Object.keys(input || {}).reduce((formData, key) => {
109
- const property = input[key];
110
- formData.append(
109
+ const property = input[key];
110
+
111
+ // array of property should be added item by item in formData with the same key
112
+ if (Array.isArray(property)) {
113
+ for (const item of property) {
114
+ formData.append(
111
115
key,
112
- property instanceof Blob ?
113
- property :
114
- typeof property === "object" && property !== null ?
115
- JSON.stringify(property) :
116
- `${property}`
116
+ item instanceof Blob ? item : typeof item === "object" && item !== null ? JSON.stringify(item) : `${item}`
117
+ );
118
+ }
119
+ } else {
120
+ formData.append(
121
+ key,
122
+ property instanceof Blob
123
+ ? property
124
+ : typeof property === "object" && property !== null
125
+ ? JSON.stringify(property)
126
+ : `${property}`
117
127
);
118
- return formData;
128
+ }
129
+
130
+ return formData;
119
131
}, new FormData()),
120
132
[ContentType.UrlEncoded]: (input: any) => this.toQueryString(input),
121
133
}
You can’t perform that action at this time.
0 commit comments