Skip to content

Commit

Permalink
feat(backport): added ability for paramsSerializer to handle function; (
Browse files Browse the repository at this point in the history
  • Loading branch information
DigitalBrainJS committed Feb 12, 2024
1 parent 80c3d74 commit 27c0076
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion index.d.ts
Expand Up @@ -122,6 +122,10 @@ export interface ParamEncoder {
(value: any, defaultEncoder: (value: any) => any): any;
}

export interface CustomParamsSerializer {
(params: Record<string, any>, options?: ParamsSerializerOptions): string;
}

export interface ParamsSerializerOptions extends SerializerOptions {
encode?: ParamEncoder;
}
Expand All @@ -134,7 +138,7 @@ export interface AxiosRequestConfig<D = any> {
transformResponse?: AxiosResponseTransformer | AxiosResponseTransformer[];
headers?: AxiosRequestHeaders;
params?: any;
paramsSerializer?: ParamsSerializerOptions;
paramsSerializer?: ParamsSerializerOptions | CustomParamsSerializer;
data?: D;
timeout?: number;
timeoutErrorMessage?: string;
Expand Down
4 changes: 4 additions & 0 deletions lib/core/Axios.js
Expand Up @@ -59,6 +59,10 @@ Axios.prototype.request = function request(configOrUrl, config) {
}, false);
}

var paramsSerializer = config.paramsSerializer;

utils.isFunction(paramsSerializer) && (config.paramsSerializer = {serialize: paramsSerializer});

// filter out skipped interceptors
var requestInterceptorChain = [];
var synchronousRequestInterceptors = true;
Expand Down

0 comments on commit 27c0076

Please sign in to comment.