fix: 🔊 Improved output

main
Keith Irwin 2024-04-21 12:33:09 -06:00
parent 9e0ec5a5c3
commit c4eca58702
Signed by: ki9
GPG Key ID: DF773B3F4A88DA86
2 changed files with 14 additions and 16 deletions

28
main.js
View File

@ -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
}
}

View File

@ -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": {