UNPKG

@busymango/fetch-driver

Version:

fetch with middlewares for the browser

31 lines (30 loc) 986 B
import type { DriveContextOptions } from "./model"; export default class DriveContext<T = unknown> { /** the fetch src */ api: string; /** the fetch init options */ options: DriveContextOptions; /** the fetch response body (parse val) */ body?: T; /** the fetch request body */ data?: object; /** the fetch response */ response?: Response; /** the response type */ responseType?: string; /** the response charset */ responseCharset?: string; constructor(api: string, data?: object, params?: RequestInit); /** init request src */ private initApi; /** init request body */ private initBody; /** init method */ private initMethod; /** init context */ init: () => void; /** use `AbortController` abort cur fetch when timeout */ initAbort: (timeout?: number) => void; /** get Content-Type & charset by response header before response */ decodeHeader: (response: Response) => void; }