@@ -28,31 +28,27 @@ export class BaseService {
2828 return consumes.indexOf(' multipart/form-data' ) !== -1;
2929 }
3030
31- protected addToHttpParams(httpParams: HttpParams, value: any, key?: string, isDeep? : boolean): HttpParams {
31+ protected addToHttpParams(httpParams: HttpParams, value: any, key?: string, isDeep: boolean = false ): 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- }
37- return this.addToHttpParamsRecursive(httpParams, value);
34+ return this.addToHttpParamsRecursive(httpParams, value, isDeep ? key : undefined, isDeep);
3835 }
3936 return this.addToHttpParamsRecursive(httpParams, value, key);
4037 }
4138
42- protected addToHttpParamsRecursive(httpParams: HttpParams, value?: any, key?: string, isDeep? : boolean): HttpParams {
39+ protected addToHttpParamsRecursive(httpParams: HttpParams, value?: any, key?: string, isDeep: boolean = false ): HttpParams {
4340 if (value === null || value === undefined) {
4441 return httpParams;
4542 }
4643 if (typeof value === 'object') {
4744 // If JSON format is preferred, key must be provided.
4845 if (key != null) {
49- if ( isDeep) {
50- return Object.entries(value as Record< string, any> ).reduce(
46+ return isDeep
47+ ? Object.entries(value as Record< string, any> ).reduce(
5148 (hp, [k, v]) => hp.append(`${key} [${ k} ]`, v),
5249 httpParams,
53- );
54- }
55- return httpParams.append(key, JSON.stringify(value));
50+ )
51+ : httpParams.append(key, JSON.stringify(value));
5652 }
5753 // Otherwise, if it's an array, add each element.
5854 if (Array.isArray(value)) {
0 commit comments