utils.d.ts 1.1 KB

123456789101112131415161718192021222324252627282930
  1. import { DageRequestConfig, DageRequestMethod } from "./types";
  2. /**
  3. * 转换 Headers 为 对象形式
  4. * @param headers
  5. */
  6. export declare function headersToObject(headers: Headers): Record<string, string>;
  7. /**
  8. * 能携带参数的请求方法
  9. * @param method
  10. */
  11. export declare function methodsHasBody(method: DageRequestMethod): boolean;
  12. /**
  13. * 序列化载荷
  14. * @param headers
  15. * @param body
  16. */
  17. export declare function serializeBody(headers: Record<string, string>, body: any): any;
  18. export declare function isFormData(value: any): boolean;
  19. export declare function isBlob(value: any): boolean;
  20. export declare function isArrayBuffer(value: any): boolean;
  21. /**
  22. * 根据body生成对应的contentType
  23. * @param body http body
  24. */
  25. export declare function detectContentType(body: any): string | null;
  26. export declare function getResponseType(config: DageRequestConfig): DageRequestMeta["responseType"];
  27. export declare function serializeResponseBody(res: globalThis.Response, config: DageRequestConfig): Promise<Record<string, any> & {
  28. data: any;
  29. }>;
  30. //# sourceMappingURL=utils.d.ts.map