UNPKG

@metis-w/api-client

Version:

Modern TypeScript HTTP API client with dynamic routes, parameterized endpoints, interceptors, and advanced features

37 lines 1.5 kB
export declare class DataSerializer { /** * Serializes data to a JSON string, handling File and Blob objects. * @param data - The data to serialize. * @returns A JSON string representation of the data. */ static hasFiles(data: any): boolean; /** * Returns the appropriate content type based on the presence of files in the data. * If files are present, returns undefined (indicating multipart/form-data). * Otherwise, returns "application/json". * @param data - The data to check. * @returns The content type string or undefined. */ static getContentType(data: any): string | undefined; /** * Serializes data to a string or FormData, depending on whether it contains files. * @param data - The data to serialize. * @returns A JSON string or FormData instance. */ static serialize(data: any): string | FormData; /** * Checks if the data contains any File or Blob objects. * @param data - The data to check. * @returns True if the data contains files, false otherwise. */ private static containsFiles; /** * Converts data to FormData, handling nested objects and arrays. * @param data - The data to convert. * @param formData - The FormData instance to append to. * @param prefix - The prefix for nested fields. * @returns A FormData instance with the serialized data. */ private static toFormData; } //# sourceMappingURL=data-serializer.d.ts.map