Skip to content

fillRoute

Describes@ebitex/content-sdk 1.xSee the changelog:@ebitex/content-sdk

fillRoute<TPattern>(pattern, params): string

Fills a pattern with a value for each parameter, percent-encoding every value, so the result is a path to link to or navigate to. Throws when a parameter has no value or an empty one: an address with a hole in it is never what a caller meant.

fillRoute('/products/{key}', { key: 'trail runner' }) // '/products/trail%20runner'

With a pattern the compiler can read (a string literal), the values are checked at compile time.

TPattern extends string

TPattern

RouteParams<TPattern>

string