infinitered / apisauce

Axios + standardized errors + request/response transforms.
MIT License
2.8k stars 184 forks source link

Add query string param support for POST #191

Closed jsphstls closed 5 years ago

jsphstls commented 5 years ago

POST requests are allowed to have query string parameters but I see now way to do this in apisauce. Since POST allows a "data" property, why not also support a "params" property that affects the query string.

robinheinze commented 5 years ago

The third parameter on all request types is a config object passed to axios, and it overrides everything. So if you need to pass params, you should be able to do something like:

apisauce.post("https://example.com", { myData: {} }, { params: { myQuery: "foo" }})

The full list of options available in this config object can be found in the Axios docs (https://github.com/axios/axios#request-config)

jsphstls commented 5 years ago

Thanks @robinheinze , I'm glad there is a workaround. Is this something that can be directly supported by ApiSauce in the future rather than using the override ?

jamonholmgren commented 5 years ago

From my standpoint, the override is actually the API I'd want to see (third argument, object with params property). The second argument is reserved for actual data. I don't think the data property is a special one there, as @robinheinze showed you can use myData or foo or whatever.

apisauce.post(url, data, options)