2.0.1 • Published 7 months ago

@samlior/http-client v2.0.1

Weekly downloads
-
License
GPL-3.0-or-later
Repository
github
Last release
7 months ago

@samlior/http-client

@samlior/http-client is an interruptible HTTP client based on JSONRPC.

Install

npm install @samlior/http-client

Usage

import { HTTPClient } from "@samlior/http-client";

const client = new HTTPClient("https://aaa.bbb.ccc");

const { aborter, getResult } = client.request("method", "params");

getResult
  .then((response) => console.log("response:", response))
  .catch((err) => console.log("error:", err));

process.on("SIGINT", () => {
  aborter.abort(new Error("SIGINT"));
  // OR
  // client.abort(new Error("SIGINT"));

  // do something...

  process.exit(0);
});