Browse Source
Merge pull request #11601 from abpframework/fix/11524
fix http param creation
pull/11603/head
Bunyamin Coskuner
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
6 additions and
5 deletions
-
npm/ng-packs/packages/core/src/lib/services/rest.service.ts
|
|
|
@ -51,14 +51,15 @@ export class RestService { |
|
|
|
} |
|
|
|
|
|
|
|
private getParams(params: Rest.Params, encoder?: HttpParameterCodec): HttpParams { |
|
|
|
const httpParams = encoder ? new HttpParams({ encoder }) : new HttpParams(); |
|
|
|
return Object.keys(params).reduce((acc, key) => { |
|
|
|
const filteredParams = Object.keys(params).reduce((acc, key) => { |
|
|
|
const value = params[key]; |
|
|
|
|
|
|
|
if (isUndefinedOrEmptyString(value)) return acc; |
|
|
|
if (value === null && !this.options.sendNullsAsQueryParam) return acc; |
|
|
|
acc = acc.set(key, value); |
|
|
|
acc[key] = value; |
|
|
|
return acc; |
|
|
|
}, httpParams); |
|
|
|
}, {}); |
|
|
|
return encoder |
|
|
|
? new HttpParams({ encoder, fromObject: filteredParams }) |
|
|
|
: new HttpParams({ fromObject: filteredParams }); |
|
|
|
} |
|
|
|
} |
|
|
|
|