File tree Expand file tree Collapse file tree 1 file changed +10
-8
lines changed
templates/base/http-clients Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -80,20 +80,22 @@ export class HttpClient<SecurityDataType = unknown> {
80
80
}
81
81
82
82
protected addArrayQueryParam(query: QueryParamsType, key: string) {
83
- const value = query[key];
84
- return value.map((v: any) => this.encodeQueryParam(key, v)).join("& ");
83
+ const value = Array.isArray(query[key])
84
+ ? query[key].map((value, index) => [index, value])
85
+ : Object.entries(query[key]);
86
+ return value.map(([arrayKey, value]: any) => this.encodeQueryParam(`${key}[${arrayKey}]`, value)).join("& ");
85
87
}
86
88
87
89
protected toQueryString(rawQuery?: QueryParamsType): string {
88
90
const query = rawQuery || {};
89
91
const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]);
90
92
return keys
91
- .map((key) =>
92
- Array.isArray(query[key])
93
- ? this.addArrayQueryParam(query, key)
94
- : this.addQueryParam(query, key),
95
- )
96
- .join("& ");
93
+ .map((key) =>
94
+ typeof query[key] === "object" || Array.isArray(query[key])
95
+ ? this.addArrayQueryParam(query, key)
96
+ : this.addQueryParam(query, key),
97
+ )
98
+ .join("& ");
97
99
}
98
100
99
101
protected addQueryParams(rawQuery?: QueryParamsType): string {
You can’t perform that action at this time.
0 commit comments