Home > widget-integration > FilterUrlHelper > buildQueryParams
FilterUrlHelper.buildQueryParams() method
Builds a URLSearchParams object from filter API parameters.
Converts a FilterAPIParams object into URLSearchParams format, handling both single values and arrays. Array values are appended with [] suffix.
Signature:
buildQueryParams(params: FilterAPIParams): URLSearchParams;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
params |
The filter parameters to convert. Keys should be filter parameter names, values can be strings, numbers, booleans, or arrays. Undefined values are skipped. |
Returns:
URLSearchParams
URLSearchParams object with sorted parameters ready for URL construction
Example
Build query params from filter data:
const params = {
'pf_brand': ['Nike', 'Adidas'],
'pf_price': '0-100',
'sort': 'price-asc'
};
const queryParams = this.buildQueryParams(params);
// Results in: pf_brand[]=Nike&pf_brand[]=Adidas&pf_price=0-100&sort=price-asc