1

I'm trying to make a GET request in Axios with what I believe are "percent encoded" parameters. D

I am trying to call a URL that should resolve to: https://example.com/api/list?pageSize=15&statusFilters=%5B"DELETED"%2C"DRAFT"%5D

Below is my code, however this resolves to https://example.com/api/list?pageSize=15&statusFilters[]=LIVE&statusFilters[]=DRAFT which for some bonkers reason returns a completely different set of results (not my API)

var params = {
  pageSize: 15,
  statusFilters: ["LIVE","DRAFT"]
}

return axios({
    method: 'GET',
    params,
    url: `${API_URL}${url}`,
})
K20GH
  • 6,032
  • 20
  • 78
  • 118
  • 3
    Use JavaScript native's function [encodeURI()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI) function – Dez Apr 17 '19 at 16:45
  • How do I go about using that on the params? – K20GH Apr 17 '19 at 16:52
  • Ah, now I get what is your problem. I think this [question](https://stackoverflow.com/questions/42898009/multiple-fields-with-same-key-in-query-params-axios-request) is what you need. – Dez Apr 17 '19 at 22:05
  • Possible duplicate of [Multiple fields with same key in query params (axios request)?](https://stackoverflow.com/questions/42898009/multiple-fields-with-same-key-in-query-params-axios-request) – Dez Apr 17 '19 at 22:06

0 Answers0