diff --git a/dev/json-rpc.js b/dev/json-rpc.js index 6bc9f47b..c5fcb028 100644 --- a/dev/json-rpc.js +++ b/dev/json-rpc.js @@ -2,13 +2,14 @@ const rpc = require('../lib/plugins/common/json-rpc') const account = { username: 'test', - password: 'test' + password: 'test', + port: 8080 } const method = {} const params = { - url: 'https://httpstat.us/500' + // url: 'https://httpstat.us/500' // url: 'https://httpstat.us/400' // url: 'https://httpstat.us/200' } diff --git a/lib/plugins/common/json-rpc.js b/lib/plugins/common/json-rpc.js index 0636b73c..fc6b3a14 100644 --- a/lib/plugins/common/json-rpc.js +++ b/lib/plugins/common/json-rpc.js @@ -6,7 +6,7 @@ const _ = require('lodash/fp') module.exports = {fetch, parseConf} -function fetch (account, method, params) { +function fetch (account = {}, method = {}, params = {}) { return Promise.resolve(true) .then(() => { const data = { @@ -14,6 +14,9 @@ function fetch (account, method, params) { params, id: uuid.v4() } + + if (_.isNil(account.port)) throw new Error('port attribute required for jsonRpc') + const url = _.defaultTo(`http://localhost:${account.port}`, params.url) return axios({