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 @@ -81,20 +81,22 @@ export class HttpClient<SecurityDataType = unknown> {
81
81
}
82
82
83
83
protected addArrayQueryParam(query: QueryParamsType, key: string) {
84
- const value = query[key];
85
- return value.map((v: any) => this.encodeQueryParam(key, v)).join("& ");
84
+ const value = Array.isArray(query[key])
85
+ ? query[key].map((value, index) => [index, value])
86
+ : Object.entries(query[key]);
87
+ return value.map(([arrayKey, value]: any) => this.encodeQueryParam(`${key}[${arrayKey}]`, value)).join("& ");
86
88
}
87
89
88
90
protected toQueryString(rawQuery?: QueryParamsType): string {
89
91
const query = rawQuery || {};
90
92
const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]);
91
93
return keys
92
- .map((key) =>
93
- Array.isArray(query[key])
94
- ? this.addArrayQueryParam(query, key)
95
- : this.addQueryParam(query, key),
96
- )
97
- .join("& ");
94
+ .map((key) =>
95
+ typeof query[key] === "object" || Array.isArray(query[key])
96
+ ? this.addArrayQueryParam(query, key)
97
+ : this.addQueryParam(query, key),
98
+ )
99
+ .join("& ");
98
100
}
99
101
100
102
protected addQueryParams(rawQuery?: QueryParamsType): string {
You can’t perform that action at this time.
0 commit comments