-
-
Notifications
You must be signed in to change notification settings - Fork 11.5k
use qs style by default for params #1565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
To keep the current behavior it will be necessary to use the If you just want to use brackets you can use the The default formatting is now more complete and corresponds to qs. The ideal would be to be able to remove the compatibility options and return to the documentation of a library as qs to use paramsSerializer as soon as the configuration is no longer the default one. |
|
When an object is passed as And we should add the option axios.get(
"/url",
{ params: { a: ["b", "c"] } },
{ paramsSerializer: { arrayFormat: "indices" } }
);
// '/url?a[0]=b&a[1]=c'
axios.get(
"/url",
{ params: { a: ["b", "c"] } },
{ paramsSerializer: { arrayFormat: "brackets" } }
);
// '/url?a[]=b&a[]=c'
axios.get(
"/url",
{ params: { a: ["b", "c"] } },
{ paramsSerializer: { arrayFormat: "repeat" } }
);
// '/url?a=b&a=c' |
|
On this I don't think this should be implement as mentioned previously if you'd like to use another format, you can set a custom paramsSerializer as follows: axios.defaults.paramsSerializer: function(params) {
// return a query string
}Using the qs library: axios.defaults.paramsSerializer: function(params) {
return qs.stringify(params, { indices: false }); // param=value1¶m=value2
} |
No description provided.