0

I am trying to make get requests using axios but parameters that have spaces are encoded using + yet the server is expecting something like %A. How do I make axios to use this same formatting style. Here is my sample request

this.$requestInstance.get(endpoint, { params })

And this is what axios makes out of it

https://emata-coopmis-api-test.laboremus.no/api/ledger/cooperatives/106aeb4d-71c7-4601-abe1-abd7d47f9df1/prices?EffectiveDateRange.From=2019-11-5+12:00:00&EffectiveDateRange.To=2019-11-5+11:59:59&ShowDailyPrices=false

In this case the spaces are in the EffectiveDateRange.From and EffectiveDateRange.To params

This is what the server expects https://emata-coopmis-api-test.laboremus.no/api/ledger/cooperatives/106aeb4d-71c7-4601-abe1-abd7d47f9df1/prices?EffectiveDateRange.From=2019-11-5%2012%3A00%3A00&EffectiveDateRange.To=2019-11-5%2023%3A59%3A59&ShowDailyPrices=true enter code here

Anjayluh
  • 1,647
  • 1
  • 13
  • 22
  • see this solution: https://stackoverflow.com/questions/58283246/axios-get-request-param-with-whitespace – Mahamudul Hasan Feb 25 '20 at 06:22
  • I tried it and it did nothing for me @MdMahamudulHasan – Anjayluh Feb 25 '20 at 06:31
  • @Anjayluh What exactly did you try and what did not work? Because this is how it's supposed to be done in Axios, to provide custom `paramsSerializer`. You can use `qs` lib for that, as the docs show, https://github.com/axios/axios#request-config – Estus Flask Feb 25 '20 at 07:12

0 Answers0