fix json-rpc issue
This commit is contained in:
parent
0c893f5b22
commit
dcef083d49
2 changed files with 17 additions and 15 deletions
|
|
@ -6,7 +6,9 @@ const _ = require('lodash/fp')
|
|||
|
||||
module.exports = {fetch, parseConf}
|
||||
|
||||
function fetch (account = {}, method = {}, params = {}) {
|
||||
function fetch (account = {}, method, params) {
|
||||
params = _.defaultTo([], params)
|
||||
|
||||
return Promise.resolve(true)
|
||||
.then(() => {
|
||||
const data = {
|
||||
|
|
@ -16,8 +18,8 @@ function fetch (account = {}, method = {}, params = {}) {
|
|||
}
|
||||
|
||||
if (_.isNil(account.port)) throw new Error('port attribute required for jsonRpc')
|
||||
|
||||
const url = _.defaultTo(`http://localhost:${account.port}`, params.url)
|
||||
|
||||
const url = _.defaultTo(`http://localhost:${account.port}`, account.url)
|
||||
|
||||
return axios({
|
||||
method: 'post',
|
||||
|
|
@ -33,8 +35,8 @@ function fetch (account = {}, method = {}, params = {}) {
|
|||
.catch(err => {
|
||||
throw new Error(_.join(' ', [
|
||||
'json-rpc::axios error:',
|
||||
_.get('message', err, ''),
|
||||
_.get('response.data.error', err, '')
|
||||
JSON.stringify(_.get('message', err, '')),
|
||||
JSON.stringify(_.get('response.data.error', err, ''))
|
||||
]))
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue