Skip to content

buildUri()

@blobs/sdk v0.1.0


@blobs/sdk / utils/query / buildUri

buildUri(template, pathParams?, query?): string

Defined in: utils/query.ts:60

Build a URI from a template and params. Path tokens are encoded.

buildUri(‘/blobs/{id}’, { id: ‘abc’ }) → ‘/blobs/abc’ buildUri(‘/blobs’, undefined, { limit: 50 }) → ‘/blobs?limit=50’

Parameters

template

string

Path template containing {name} tokens.

pathParams?

Record<string, string | number>

Values to substitute for the path tokens.

query?

QueryRecord

Optional query parameters appended via buildQuery.

Returns

string

The composed URI.

Throws

If a token in template has no corresponding entry in pathParams (catches typos early).