Skip to content
0

katanakit-js / useBuildUrl

Function: useBuildUrl() ​

ts
function useBuildUrl(
   apiName, 
   endpointName, 
   options?
): string;

Defined in: src/core/services/http.service.ts:661

Returns the URL of a registered endpoint without calling fetch.

Parameters ​

ParameterTypeDescription
apiNamestringRegistered API key (from defineApiConfig).
endpointNamestringEndpoint key inside that API.
optionsUrlOptionsparams fills :placeholders, query becomes the search string.

Returns ​

string

The fully built URL.

Throws ​

Unknown API, unknown endpoint, or a scheme that is not http(s).

Example ​

ts
import { useBuildUrl } from "katanakit-js";

useBuildUrl("pokeapi", "pokemonById", { params: { id: 25 } });
// → "https://pokeapi.co/api/v2/pokemon/25"

Released under the MIT License.