hobby-rpc
v0.1.1
Published
A Hobby-RPC client for browsers
Downloads
3
Readme
It is a Hobby-RPC client for browsers, using the built-in Fetch API. To install:
npm i hobby-rpc
A usage example:
import { RPC } from 'hobby-rpc'
rpc = RPC
url: 'https://some.domain'
token: 'the bearer token'
output = await rpc 'SomeNullaryFunction'
output = await rpc 'SomeUnaryFunction', input
input
can be any object serializable to JSON
(that's what will be passed to the remote function as an argument).
The remote server at https://some.domain is expected to implement
SomeNullaryFunction
and SomeUnaryFunction
.
output
would be an object deserialized from JSON.