@cedra-labs/cedra-client
v2.0.2
Published
Client package for accessing the Cedra network API.
Downloads
155
Readme
@cedra-labs/cedra-client
This package implements a client with which you can interact with the Cedra network. It can be used standalone, and it is the client package used by the Cedra TypeScript SDK.
Implementation
The @cedra-labs/cedra-client package supports http2 protocol and implements 2 clients environment based:
- fetch - implemented in
index.browser.tsto use inbrowserenvironment (in a browser env it is up to the browser and the server to negotiate http2 connection) - got - implemented in
index.node.tsto use innodeenvironment (to support http2 in node environment, still the server must support http2 also)
Function signature
async function cedraClient<Res>(
requestOptions: CedraClientRequest,
): Promise<CedraClientResponse<Res>>;Types
type CedraClientResponse<Res> = {
status: number;
statusText: string;
data: Res;
config?: any;
request?: any;
response?: any;
headers?: any;
};
type CedraClientRequest = {
url: string;
method: "GET" | "POST";
body?: any;
params?: any;
headers?: any;
overrides?: any;
};Usage
import cedraClient from "@cedra-labs/cedra-client";
const response = await cedraClient<Res>({
url,
method,
body,
params,
headers,
overrides,
});
return response;