Skip to content

urlParams

urlParams(values): string

Defined in: core/utils/url.ts:18

Returns a query string, ready to append to a URL after ?.

A string is returned as it is, so callers can accept either form. For an object, each own property becomes a key=value pair with both sides passed through encodeURIComponent. Properties whose value is null or undefined are left out.

string | object

A query string, or an object of parameter names and values.

string

urlParams('animal=cat&fruit=apple'); // 'animal=cat&fruit=apple'
urlParams({ animal: 'cat', fruit: 'apple' }); // 'animal=cat&fruit=apple'
urlParams({ q: 'a b', skip: undefined }); // 'q=a%20b'