@rpcbase/client 0.185.0 → 0.186.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/rpc.js +32 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpcbase/client",
3
- "version": "0.185.0",
3
+ "version": "0.186.0",
4
4
  "scripts": {
5
5
  "test": "../../node_modules/.bin/wireit"
6
6
  },
package/rpc.js ADDED
@@ -0,0 +1,32 @@
1
+ /* @flow */
2
+ // import assert from "assert"
3
+ import axios from "axios"
4
+
5
+ import {SERVER_PORT} from "env"
6
+
7
+ export const rpcClientPost = async(rpcName, payload) => {
8
+ const baseUrl = `http://localhost:${SERVER_PORT}`
9
+ const rpcUrl = `/rpc/${rpcName.replace("server/", "")}`
10
+
11
+ const reqUrl = `${baseUrl}${rpcUrl}`
12
+
13
+ let res
14
+ try {
15
+ res = await axios.post(reqUrl, payload, {
16
+ // headers: {"x-native-app": "yes"},
17
+ withCredentials: true,
18
+ headers: {
19
+ "user-agent": "rb-rpc-client/dev"
20
+ }
21
+ })
22
+ } catch (err) {
23
+ console.log("RPC got err", err)
24
+ console.log(err.message)
25
+ console.log(err.response)
26
+ }
27
+
28
+ // console.log("LABASE", baseUrl)
29
+ // console.log("GOT RPC CALL", rpcName, payload)
30
+ // console.log("LARES", res.data)
31
+ return res.data
32
+ }