json-rpc-response

1.0.3 • Public • Published

JSON RPC 2.0 Response

Constructor for JSON RPC 2.0 response objects.

Also see related packages json-rpc-request, json-rpc-notification, and json-rpc-error

Installation

npm install json-rpc-response

Usage

new JsonRpcResponse(id, error, result);

Response objects can be constructed with or without using the new keyword.

Arguments error and result are mutually exclusive. Argument result must be undefined if passing error. Pass null as error if result exists.

Example

var JsonRpcResponse = require('json-rpc-response');
 
// Result response
new JsonRpcResponse(1, null, 'some result');
 
// Error response
new JsonRpcResponse(1, { code: -1, message: 'some error' });

Test

Run unit tests;

$ npm test

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i json-rpc-response

Weekly Downloads

0

Version

1.0.3

License

MIT

Last publish

Collaborators

  • claudijo