@samlior/http-client
v2.0.1
Published
`@samlior/http-client` is an interruptible HTTP client based on JSONRPC.
Downloads
3
Readme
@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);
});