Function: useFetch()
useFetch<
T>(apiName,endpointName,options?):Promise<FetchResult<T>>
Defined in: src/core/services/http.service.ts:285
Fetches a registered endpoint and returns a Safe Result.
Type Parameters
T
T = unknown
Parameters
apiName
string
The registered API key.
endpointName
string
The endpoint key within the API.
options?
FetchOptions = {}
Optional fetch options (method, headers, body, urlOptions).
Returns
Promise<FetchResult<T>>
A FetchResult with data or error.
Example
import { useFetch } from "katanakit-js";
const result = await useFetch("pokeapi", "pokemonById", {
method: "GET",
urlOptions: { params: { id: 25 } },
});
if (result.ok) console.log(result.data);