Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jrpc2-client

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jrpc2-client

JSON-RPC 2.0 library, with custom data fetching providers

  • 1.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
Maintainers
1
Weekly downloads
 
Created
Source

JSON RPC 2.0 Client

Zero dependecy JSON-RPC 2.0 client. With custom data providers, batch call, work with each result of operation as promise

Providers out the box:

  • JrpcFetchProvider - native fetch
  • JrpcAxiosProvider - axios instance

Example

import { JrpcClient, JrpcAxiosProvider } from "jrpc2-client";
import axios from "axios";

const jrpc = new JrpcClient(
  new JrpcAxiosProvider(
    axios.create({
      baseURL: "https://example.com/jrpc",
      method: "POST",
    })
  )
);

// Single call
jrpc.call("methodName", { param1: "value" }).then((result) => null);

// Batch call
jrpcClient
  .batch(
    jrpcClient.createCall("method1", "value"),
    jrpcClient.createCall("method2", "value")
  )
  .then((results) => null);

// Also can call batch with directly work every operation
const call1 = jrpcClient.createCall("method1", "value");
call1.then((result1) => null);
const call2 = jrpcClient.createCall("method2", "value");
call2.then((result2) => null);

jrpcClient.batch(call1, call2);

Keywords

FAQs

Package last updated on 28 Jul 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc