Skip to content

Commit

Permalink
fix: GET query requests
Browse files Browse the repository at this point in the history
  • Loading branch information
kdoran committed Apr 14, 2020
1 parent 30fbfac commit 621f90e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions app/containers/QueryContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,13 @@ export default class QueryContainer extends React.Component {
}

const { fetchParams, parse } = parsedInput
const {url} = fetchParams
let {url} = fetchParams
delete fetchParams.url
fetchParams.body = JSON.stringify(fetchParams.body)
if (fetchParams.params) {
url = `${url}?${getParams(fetchParams.params)}`
} else {
fetchParams.body = JSON.stringify(fetchParams.body)
}
try {
const response = await this.props.api.fetcher(url, fetchParams)
const result = parse(response)
Expand Down Expand Up @@ -184,3 +188,7 @@ export default class QueryContainer extends React.Component {
)
}
}

function getParams (data) {
return Object.keys(data).map(key => [key, data[key]].map(encodeURIComponent).join('=')).join('&')
}

0 comments on commit 621f90e

Please sign in to comment.