@@ -42,14 +42,14 @@ The server accepts a dictionary of resolvers.
42
42
import { createServer } from " @borderless/json-rpc" ;
43
43
44
44
const server = createServer <Methods >({
45
- hello : _ => " Hello World!" ,
46
- echo : ({ arg }) => arg
45
+ hello : ( _ ) => " Hello World!" ,
46
+ echo : ({ arg }) => arg ,
47
47
});
48
48
49
49
const res = await server ({
50
50
jsonrpc: " 2.0" ,
51
51
id: " test" ,
52
- method: " hello"
52
+ method: " hello" ,
53
53
}); // => { jsonrpc: "2.0", id: "test", result: "Hello World!" }
54
54
```
55
55
@@ -60,32 +60,32 @@ The client accepts a function to `send` the JSON-RPC request.
60
60
``` ts
61
61
import { createClient } from " @borderless/json-rpc" ;
62
62
63
- const client = createClient (async payload => {
63
+ const client = createClient (async ( payload ) => {
64
64
const res = await fetch (" ..." , {
65
65
method: " POST" ,
66
66
body: JSON .stringify (payload ),
67
67
headers: {
68
- " Content-Type" : " application/json"
69
- }
68
+ " Content-Type" : " application/json" ,
69
+ },
70
70
});
71
71
72
72
return res .json ();
73
73
});
74
74
75
75
const result = await client ({
76
76
method: " hello" ,
77
- params: {}
77
+ params: {},
78
78
}); // => "Hello World!"
79
79
80
80
const results = await client .many ([
81
81
{
82
82
method: " hello" ,
83
- params: {}
83
+ params: {},
84
84
},
85
85
{
86
86
method: " echo" ,
87
- params: { arg: " Test" }
88
- }
87
+ params: { arg: " Test" },
88
+ },
89
89
]); // => ["Hello World!", "Test"]
90
90
```
91
91
0 commit comments