json-rpc parameter bugfix (#129)

* json-rpc parameter bugfix

* small change

* Update json-rpc.js
This commit is contained in:
Fabio Cigliano 2018-07-02 02:43:58 +12:00 committed by Josh Harvey
parent dd7e447e73
commit 1bcf586544
2 changed files with 7 additions and 3 deletions

View file

@ -2,13 +2,14 @@ const rpc = require('../lib/plugins/common/json-rpc')
const account = { const account = {
username: 'test', username: 'test',
password: 'test' password: 'test',
port: 8080
} }
const method = {} const method = {}
const params = { const params = {
url: 'https://httpstat.us/500' // url: 'https://httpstat.us/500'
// url: 'https://httpstat.us/400' // url: 'https://httpstat.us/400'
// url: 'https://httpstat.us/200' // url: 'https://httpstat.us/200'
} }

View file

@ -6,7 +6,7 @@ const _ = require('lodash/fp')
module.exports = {fetch, parseConf} module.exports = {fetch, parseConf}
function fetch (account, method, params) { function fetch (account = {}, method = {}, params = {}) {
return Promise.resolve(true) return Promise.resolve(true)
.then(() => { .then(() => {
const data = { const data = {
@ -14,6 +14,9 @@ function fetch (account, method, params) {
params, params,
id: uuid.v4() id: uuid.v4()
} }
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}`, params.url)
return axios({ return axios({