fix: 🔊 Improved output
parent
9e0ec5a5c3
commit
c4eca58702
28
main.js
28
main.js
|
@ -30,21 +30,19 @@ module.exports = class Wallet {
|
|||
}
|
||||
|
||||
async rpc(method, params=undefined) {
|
||||
let res; try {
|
||||
res = await axios.post(`${this.url}/json_rpc`, {
|
||||
jsonrpc: '2.0',
|
||||
id: '0',
|
||||
method: method,
|
||||
params: params,
|
||||
})
|
||||
if (res.status!==200)
|
||||
throw new Error(res.statusText)
|
||||
if (res.data.error)
|
||||
throw new Error(res.data.error.message)
|
||||
if (!res.data.result)
|
||||
throw new Error('No result sent')
|
||||
} catch (err) { console.error(err) }
|
||||
return res.data.result
|
||||
const res = await axios.post(`${this.url}/json_rpc`, {
|
||||
jsonrpc: '2.0',
|
||||
id: '0',
|
||||
method: method,
|
||||
params: params,
|
||||
})
|
||||
if (res.status!==200)
|
||||
throw new Error(res.statusText)
|
||||
else if (res.data.error)
|
||||
throw new Error(res.data.error.message)
|
||||
else if (!res.data.result)
|
||||
throw new Error('No result')
|
||||
else return res.data.result
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "monero-wallet-rpc-js",
|
||||
"type": "commonjs",
|
||||
"version": "1.2.0",
|
||||
"version": "1.2.1",
|
||||
"description": "Javascript wrapper for monero-wallet-rpc calls",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
|
Loading…
Reference in New Issue