Skip to content

Commit

Permalink
feat: allow to provide HttpParams in DataClientRequestOptions (#1522) (
Browse files Browse the repository at this point in the history
…#1523)

Co-authored-by: Markiewic <[email protected]>
  • Loading branch information
Markiewic and Markiewic authored Apr 10, 2024
1 parent 3427290 commit 487c5c2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { HttpParams } from '@angular/common/http';
import { Nullable, PlainObject } from '@angular-ru/cdk/typings';

export interface DataHeadersParams {
Expand Down Expand Up @@ -36,7 +37,7 @@ export interface DataClientRequestOptions<T extends PlainObject = any> {
* @description
* query params for request
*/
queryParams: Nullable<PlainObject>;
queryParams: Nullable<PlainObject> | HttpParams;

/**
* @description
Expand Down
6 changes: 5 additions & 1 deletion libs/cdk/http/utils/src/get-http-params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import { Nullable, PlainObject } from '@angular-ru/cdk/typings';

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

export function getHttpParams(path: string, params: Nullable<PlainObject>): HttpParams {
export function getHttpParams(path: string, params: Nullable<PlainObject> | HttpParams): HttpParams {
if (params instanceof HttpParams) {
return params;
}

const queryPath: PlainObject = parseQueryParams(path);
const fromObject: PlainObject = clean({ ...queryPath, ...(params ?? {}) });

Expand Down

0 comments on commit 487c5c2

Please sign in to comment.