Skip to content

Commit 487c5c2

Browse files
authored
feat: allow to provide HttpParams in DataClientRequestOptions (#1522) (#1523)
Co-authored-by: Markiewic <[email protected]>
1 parent 3427290 commit 487c5c2

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

libs/cdk/http/typings/src/interfaces/data-client-request-options.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { HttpParams } from '@angular/common/http';
12
import { Nullable, PlainObject } from '@angular-ru/cdk/typings';
23

34
export interface DataHeadersParams {
@@ -36,7 +37,7 @@ export interface DataClientRequestOptions<T extends PlainObject = any> {
3637
* @description
3738
* query params for request
3839
*/
39-
queryParams: Nullable<PlainObject>;
40+
queryParams: Nullable<PlainObject> | HttpParams;
4041

4142
/**
4243
* @description

libs/cdk/http/utils/src/get-http-params.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ import { Nullable, PlainObject } from '@angular-ru/cdk/typings';
44

55
import { parseQueryParams } from './parse-query-params';
66

7-
export function getHttpParams(path: string, params: Nullable<PlainObject>): HttpParams {
7+
export function getHttpParams(path: string, params: Nullable<PlainObject> | HttpParams): HttpParams {
8+
if (params instanceof HttpParams) {
9+
return params;
10+
}
11+
812
const queryPath: PlainObject = parseQueryParams(path);
913
const fromObject: PlainObject = clean({ ...queryPath, ...(params ?? {}) });
1014

0 commit comments

Comments
 (0)