2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-20 20:00:40 +03:00

Added enhanced toFormData implementation with additional options support; (#4704)

Updated default notation for arrays and objects to bracket style;
Added `multer/express.js` tests;
Updated README.md;

Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
Dmitriy Mozgovoy
2022-05-11 20:30:08 +03:00
committed by GitHub
parent 495d5fb133
commit 807918bda2
9 changed files with 664 additions and 87 deletions
Vendored
+19 -1
View File
@@ -79,6 +79,23 @@ export interface GenericAbortSignal {
removeEventListener: (...args: any) => any;
}
export interface FormDataVisitorHelpers {
defaultVisitor: FormDataVisitor;
convertValue: (value: any) => any;
isVisitable: (value: any) => boolean;
}
export interface FormDataVisitor {
(value: any, key: string | number, path: null | Array<string | number>, helpers: FormDataVisitorHelpers): boolean;
}
export interface FormSerializerOptions {
visitor?: FormDataVisitor;
dots?: boolean;
metaTokens?: boolean;
indexes?: boolean;
}
export interface AxiosRequestConfig<D = any> {
url?: string;
method?: Method | string;
@@ -117,6 +134,7 @@ export interface AxiosRequestConfig<D = any> {
env?: {
FormData?: new (...args: any[]) => object;
};
formSerializer?: FormSerializerOptions;
}
export interface HeadersDefaults {
@@ -268,7 +286,7 @@ export interface AxiosStatic extends AxiosInstance {
all<T>(values: Array<T | Promise<T>>): Promise<T[]>;
spread<T, R>(callback: (...args: T[]) => R): (array: T[]) => R;
isAxiosError(payload: any): payload is AxiosError;
toFormData(sourceObj: object, targetFormData?: GenericFormData): GenericFormData;
toFormData(sourceObj: object, targetFormData?: GenericFormData, options?: FormSerializerOptions): GenericFormData;
}
declare const axios: AxiosStatic;