Skip to content

AlexMercedCoder/simplerpc-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SimpleRPC - Client

npm install @alexmerced/simplerpc-client

The SimpleRPC framework is a framework for creating very simple lightweight RPC APIs for use with any backend or frontend framework with a redux/useReducer like API.

Actions take the signature of

(payload: Object, context: Object) => response:Any

The client function then can be called like so:

rpcDispatch({type: "actionName", payload: {arg1: 1, arg 2: "hello"}})

Setting up the Client

import {createClient} from "simplerpc-client"

const rpcDispatch = createClient({
    url: "http://localhost:4000/rpc",
    headers: {
        "authorization": "..."
    }
})

export default rpcDispatch

Then assuming your server is setup with @alexmerced/simplerpc-server at the specific endpoint you can make rpc calls like so.

await rpcDispatch({type: "createTodo", payload: {
    message: "Lunch"
}})

About

simplerpc client library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published