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
how to set global paramsSerializer? #5217
Comments
same problem |
Duplicate of #5206 |
paramsSerializer: { |
https://github.com/axios/axios/blob/v1.x/lib/helpers/buildURL.js#L41 paramsSerializer: {
serialize(params: Record<string, unknown>): string => {
// do your old paramsSerializer logic here
}
} from the docs: New-old ParamsSerializer support added by @DigitalBrainJS in #5113 |
same issue |
This is a breaking change, and it was introduced in a patch level version... Seems like a bad idea, and it seems like it is possible to support the old function style version... Would that be an acceptable feature request, maybe with a deprecation warning? |
Change For example encode will be called many times in the following order with the following param per call:
serialize on the other hand will be called with your entire params object like you have in the jsdoc. |
The I honestly don't know why this was changed (maybe to use the same form data logic?). It seems like the new way should have been behind some sort of feature flag. |
// you should check axios version in package.json
// axios version >1.X paramsSerializer must be Object
// The following is the npm axios document
paramsSerializer: {
encode?: (param: string): string => { /* Do custom ops here and return transformed string */ }, // custom encoder function; sends Key/Values in an iterative fashion
serialize?: (params: Record<string, any>, options?: ParamsSerializerOptions ), // mimic pre 1.x behavior and send entire params object to a custom serializer func. Allows consumer to control how params are serialized.
indexes: false // array indexes format (null - no brackets, false (default) - empty brackets, true - brackets with indexes)
}, |
|
@Spirit04eK Thanks, this was my problem. I tried config.paramsSerializer.serialize, but it does not exists here. I tought that it will be always there, but config.paramsSerializer is empty here. |
I was able to set
Using axios version Looks like it was fixed here: #5633 |
I set global paramsSerializer by code as below, hope can help u.
|
I wanted to set it up without external library and this works so far:
This is the defaultEncoder function (axios@1.6.8):
|
Describe the bug
"axios": "^1.1.3",
how to set global paramsSerializer?
To Reproduce
none
Code snippet
Expected behavior
qs success
happend
The text was updated successfully, but these errors were encountered: