Skip to content

Commit afc1465

Browse files
authored
fix: add array params with key (#237)
* fix: add array query params with key * chore: use encoded key and value for array params Co-authored-by: Sascha Galley <[email protected]>
1 parent 1d6e97a commit afc1465

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

templates/base/http-clients/fetch-http-client.eta

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,18 @@ export class HttpClient<SecurityDataType = unknown> {
6969
this.securityData = data;
7070
}
7171

72+
private encodeQueryParam(key: string, value: any) {
73+
const encodedKey = encodeURIComponent(key);
74+
return `${encodedKey}=${encodeURIComponent(typeof value === "number" ? value : `${value}`)}`;
75+
}
76+
7277
private addQueryParam(query: QueryParamsType, key: string) {
73-
const value = query[key];
74-
const encodedKey = encodeURIComponent(key);
75-
return `${encodedKey}=${encodeURIComponent(
76-
typeof value === 'number' ? value : `${value}`,
77-
)}`;
78+
return this.encodeQueryParam(key, query[key]);
7879
}
7980

8081
private addArrayQueryParam(query: QueryParamsType, key: string) {
8182
const value = query[key];
82-
return `${value.map(this.addQueryParam).join('&')}`;
83+
return value.map((v: any) => this.encodeQueryParam(key, v)).join("&");
8384
}
8485

8586
protected toQueryString(rawQuery?: QueryParamsType): string {

0 commit comments

Comments
 (0)