0.1.1 • Published 1 year ago

endless-client v0.1.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
1 year ago

@endless-labs/endless-client

This package implements a client with which you can interact with the Endless network. It can be used standalone, and it is the client package used by the Endless TypeScript SDK.

Implementation

The @endless-labs/endless-client package supports http2 protocol and implements 2 clients environment based:

  1. axios - implemented in index.browser.ts to use in browser environment (in a browser env it is up to the browser and the server to negotiate http2 connection)
  2. got - implemented in index.node.ts to use in node environment (to support http2 in node environment, still the server must support http2 also)

Function signature

async function endlessClient<Res>(requestOptions: EndlessClientRequest): Promise<EndlessClientResponse<Res>>;

Types

type EndlessClientResponse<Res> = {
  status: number;
  statusText: string;
  data: Res;
  config?: any;
  request?: any;
  response?: any;
  headers?: any;
};

type EndlessClientRequest = {
  url: string;
  method: "GET" | "POST";
  body?: any;
  params?: any;
  headers?: any;
  overrides?: any;
};

Usage

import endlessClient from "@endless-labs/endless-client";

const response = await endlessClient<Res>({ url, method, body, params, headers, overrides });
return response;
0.1.1

1 year ago