Skip to content

Commit

Permalink
Fixed Issue with missing params
Browse files Browse the repository at this point in the history
  • Loading branch information
KaniRobinson committed Oct 12, 2018
1 parent e7b50ab commit 9d33522
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/actions/Action.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ export default class Action {
let endpoint = `${model.methodConf.http.url}${model.methodConf.methods[type].http.url}`;
let params = _.map(endpoint.match(/(\/?)(\:)([A-z]*)/gm), (param) => { return param.replace('/', '') })

_.forEach(params, (param) => { endpoint = endpoint.replace(param, config.params[param.replace(':', '')] || '').replace('//', '/') })
_.forEach(params, (param) => {
const paramValue = _.has(config.params, param.replace(':', '')) ? config.params[param.replace(':', '')] : ''
endpoint = endpoint.replace(param, paramValue).replace('//', '/')
})
if (config.query) endpoint += `?${Object.keys(config.query).map(k => `${encodeURIComponent(k)}=${encodeURIComponent(config.query[k])}`).join('&')}`;
return endpoint;
}
Expand Down

0 comments on commit 9d33522

Please sign in to comment.