ch1c0t / hobby-rpc.clients.js

A Hobby-RPC client for browsers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

A Hobby-RPC client for browsers

License:BSD Zero Clause License


Languages

Language:CoffeeScript 100.0%