Function: buildUrl()
ts
function buildUrl(
base,
path?,
query?): string;Builds a URL from a base URL, path, and optional query object.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
base | string | undefined | The base URL. |
path | string | '' | The path to append. |
query | Record<string, string | number> | {} | The query object. |
Returns
string
The built URL string.
Example
ts
buildUrl('https://api.com', '/users', { page: 1 })
// => 'https://api.com/users?page=1'Since
1.0.0