backport: custom params serializer support for v0.x#6263
Conversation
originally implemented in axios#5113
| new AxiosURLSearchParams(params, options).toString(_encode); | ||
| } | ||
|
|
||
| if (serializedParams) { |
There was a problem hiding this comment.
To avoid defining hashmarkIndex also when serializedParams in a falsy value, these line
var hashmarkIndex = url.indexOf('#');
if (hashmarkIndex !== -1) {
url = url.slice(0, hashmarkIndex);
}
can be moved inside the if
| indexes: true, | ||
| encode: (value) => value | ||
| encode: (value) => value, | ||
| serialize: (value, options) => String(value) |
There was a problem hiding this comment.
Hey @briwa, I noticed the ParamsSerializerOptions type does not include the serialize prop.
The type should be aligned in the index.d.ts file.
Note: In v1.x, the ParamsSerializerOptions interface is defined like this:
export interface ParamsSerializerOptions extends SerializerOptions {
encode?: ParamEncoder;
serialize?: CustomParamsSerializer;
}
|
Hey @briwa, watching your MR I see the implementation is slightly different from the one in v1.x. IMMO this choice could create more friction for users who try to upgrade Axios from v0.x to v1.x. |
@JadeMugs Hey, I disagree that it will cause friction because as I mentioned in the PR description, this PR is simply following the same patch that was introduced in #5113. If this patch would cause friction, then the original patch would be, too, since I'm not doing anything different. But I might be wrong, so I'll let the maintainers decide. |
Resolves #6262
This will add similar support to #5113 (
paramsSerializer: { serializer? }orparamsSerializer(params) { .. }) which was missing in v0.x.Was hoping if this could be released as a patch for v0.28.x