@hamjs/rpc-client

0.0.2 • Public • Published

hamjs-rpc-client-node

A NodeJS RPC Client for @hamjs/rpc-server

How to use?

Installation

First, create your NodeJs project using npm init command. Then run command below inside that project.

npm i https://github.com/hadihammurabi/hamjs-rpc-client-node

Connecting to RPC Server

Before you connect to RPC server, don't forget to run the server first (read here)! Then, type this on your .js file.

// importing this package 
const rpc = require('@hamjs/rpc-client');

// connecting to RPC server
rpc.connect('http://localhost:8080');

Call a Procedure

All procedure calls are done with Promise. You can see example below.

// call sum procedure
// send parameters as an object
rpc
  .call('sum', { a: 1, b: 2 })
  .then(res => {
    console.log(res);
  })
  .catch(console.log);

Contributing

Read here!

Readme

Keywords

Package Sidebar

Install

npm i @hamjs/rpc-client

Weekly Downloads

0

Version

0.0.2

License

MIT

Unpacked Size

3.64 kB

Total Files

5

Last publish

Collaborators

  • hadihammurabi