Skip to content

spliceUrlParam

Splice parameters into URL.

Usage

js
import { spliceUrlParam } from 'js-cool'

Signature

typescript
function spliceUrlParam(url: string, params: Record<string, any>): string

Parameters

ParameterTypeDescription
urlstringBase URL
paramsRecord<string, any>Parameters object

Returns

string - URL with parameters.

Examples

js
spliceUrlParam('https://example.com', { name: 'John', age: 30 })
// 'https://example.com?name=John&age=30'

spliceUrlParam('https://example.com?foo=bar', { name: 'John' })
// 'https://example.com?foo=bar&name=John'

Released under the MIT License.