Skip to content
0

katanakit-js / usePost

Function: usePost() ​

ts
function usePost<T>(
   apiName, 
   endpointName, 
   body?, 
   urlOptions?
): Promise<FetchResult<T>>;

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

POST helper over a registered API endpoint.

Type Parameters ​

Type ParameterDefault type
Tunknown

Parameters ​

ParameterTypeDescription
apiNamestringThe registered API key.
endpointNamestringThe endpoint key within the API.
body?unknownOptional request body (auto-serialized to JSON unless raw).
urlOptions?UrlOptionsOptional URL building options.

Returns ​

Promise<FetchResult<T>>

A FetchResult with data or error.

Example ​

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

const result = await usePost("pokeapi", "createPokemon", { name: "Pikachu" });

Released under the MIT License.