@@ -28,21 +28,27 @@ export class BaseService {
28
28
return consumes.indexOf(' multipart/form-data' ) !== -1;
29
29
}
30
30
31
- protected addToHttpParams(httpParams: HttpParams, value: any, key?: string): HttpParams {
31
+ protected addToHttpParams(httpParams: HttpParams, value: any, key?: string, isDeep?: boolean ): HttpParams {
32
32
// If the value is an object (but not a Date), recursively add its keys.
33
33
if (typeof value === ' object' && ! (value instanceof Date)) {
34
34
return this.addToHttpParamsRecursive(httpParams, value);
35
35
}
36
- return this.addToHttpParamsRecursive(httpParams, value, key);
36
+ return this.addToHttpParamsRecursive(httpParams, value, key, isDeep );
37
37
}
38
38
39
- protected addToHttpParamsRecursive(httpParams: HttpParams, value?: any, key?: string): HttpParams {
39
+ protected addToHttpParamsRecursive(httpParams: HttpParams, value?: any, key?: string, isDeep?: boolean ): HttpParams {
40
40
if (value === null || value === undefined) {
41
41
return httpParams;
42
42
}
43
43
if (typeof value === 'object') {
44
44
// If JSON format is preferred, key must be provided.
45
45
if (key != null) {
46
+ if (isDeep) {
47
+ return Object.entries(value as Record< string, any> ).reduce(
48
+ (hp, [k, v]) => hp.append(`${key} [${ k} ]`, v),
49
+ httpParams,
50
+ );
51
+ }
46
52
return httpParams.append(key, JSON.stringify(value));
47
53
}
48
54
// Otherwise, if it's an array, add each element.
0 commit comments