diff options
| author | Adam Soltys <[email protected]> | 2023-02-06 16:48:13 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2023-02-06 16:48:13 -0800 |
| commit | 9c667055c6367e1b2e239686e72f52995679a47e (patch) | |
| tree | 0b1d4aee51ec2d4e92d08a9d1404ba4e2ecd462a /lib/rpc.js | |
| parent | 15294844dbc8e73b4d1e92008a7eebc6b86b9ec5 (diff) | |
| parent | 6f5602d112b68adb7452abf3047f20c32e7725b6 (diff) | |
| download | coinos-server-9c667055c6367e1b2e239686e72f52995679a47e.tar.gz coinos-server-9c667055c6367e1b2e239686e72f52995679a47e.zip | |
Merge branch 'master' into test
Diffstat (limited to 'lib/rpc.js')
| -rw-r--r-- | lib/rpc.js | 26 |
1 files changed, 14 insertions, 12 deletions
@@ -1,4 +1,4 @@ -import wretch from "./wretch"; +import got from "got"; export default ({ host, port, wallet, username, password }) => new Proxy( @@ -7,18 +7,20 @@ export default ({ host, port, wallet, username, password }) => get: (target, prop) => (...params) => ((method, ...params) => { let url = `http://${host}:${port}/wallet/${wallet}`; - return wretch() - .url(url) - .auth( - `Basic ${Buffer.from(`${username}:${password}`).toString( - "base64" - )}` - ) - .post({ - method, - params + return got + .post(url, { + json: { + method, + params + }, + headers: { + authorization: `Basic ${Buffer.from( + `${username}:${password}` + ).toString("base64")}` + } }) - .json(({ result }) => result); + .json() + .then(({ result }) => result); })(prop.toLowerCase(), ...params) } ); |
