@@ -28,21 +28,30 @@ export class BaseService {
2828 return consumes.indexOf(' multipart/form-data' ) !== -1;
2929 }
3030
31- protected addToHttpParams(httpParams: HttpParams, value: any, key?: string): HttpParams {
31+ protected addToHttpParams(httpParams: HttpParams, value: any, key?: string, isDeep?: boolean ): HttpParams {
3232 // If the value is an object (but not a Date), recursively add its keys.
3333 if (typeof value === ' object' && ! (value instanceof Date)) {
34+ if (isDeep) {
35+ return this.addToHttpParamsRecursive(httpParams, value, key, isDeep);
36+ }
3437 return this.addToHttpParamsRecursive(httpParams, value);
3538 }
3639 return this.addToHttpParamsRecursive(httpParams, value, key);
3740 }
3841
39- protected addToHttpParamsRecursive(httpParams: HttpParams, value?: any, key?: string): HttpParams {
42+ protected addToHttpParamsRecursive(httpParams: HttpParams, value?: any, key?: string, isDeep?: boolean ): HttpParams {
4043 if (value === null || value === undefined) {
4144 return httpParams;
4245 }
4346 if (typeof value === 'object') {
4447 // If JSON format is preferred, key must be provided.
4548 if (key != null) {
49+ if (isDeep) {
50+ return Object.entries(value as Record< string, any> ).reduce(
51+ (hp, [k, v]) => hp.append(`${key} [${ k} ]`, v),
52+ httpParams,
53+ );
54+ }
4655 return httpParams.append(key, JSON.stringify(value));
4756 }
4857 // Otherwise, if it's an array, add each element.
0 commit comments