New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

json-rpc-cli

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-rpc-cli

JSON RPC

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

json-rpc-cli

这个package 是在 JSON RPC 的客户端中使用,传入您的action和对应参数即可在JS是获取到信息;

Install

npm install json-rpc-cli --save

使用方法演示

then/catch

let rpc = require('json-rpc-cli');
const options = {
    host: "127.0.0.1",
    port: 8765
};
let client = new rpc.Client(options);

function asyncfunc(opt) {
    return new Promise((resolve, reject) => {
        client.call(opt,
            function (err, res) {
                if (err) {
                    reject(err);
                } else {
                    resolve(res)
                }
            }
        );
    })
}
console.log(' ------------- Start ------------- ')
let opt = {
    "action": "account_create",
    "password": '12345678'
};
asyncfunc(opt).then(data => {
    console.log(' ------------- Success ------------- ')
    console.log(data)
}).catch(err => {
    console.log(' ------------- Error ------------- ')
    console.log(err)
})

await/async

(async () => {
    let rpc = require('json-rpc-cli');

    const options = {
        host: "127.0.0.1",
        port: 8765
    };
    let client = new rpc.Client(options);

    function asyncfunc(opt) {
        return new Promise((resolve, reject) => {
            client.call(opt,
                function (err, res) {
                    if (err) {
                        reject(err);
                    } else {
                        resolve(res)
                    }
                }
            );
        })
    }
    console.log(' ------------- Start ------------- ')
    let opt = {
        "action": "account_create",
        "password": '12345678'
    };
    let res = await asyncfunc(opt);
    console.log(res);
    console.log(' ------------- End ------------- ')
})()

FAQs

Package last updated on 08 Nov 2019

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