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