Function: queryString()
ts
function queryString(query?, separator?): string;Converts a query object to a query string.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
query | Record<string, string | number> | null | undefined | {} | The query object to convert. |
separator | string | '?' | The separator to use between the URL and the query string (default is '?'). |
Returns
string
The generated query string.
Example
ts
queryString({ name: 'John', age: 30 }) // => '?name=John&age=30'
queryString({ q: 'hello' }, '#') // => '#q=hello'Since
1.0.0