@worker-tools/json-fetch
Version:
A drop-in replacements for fetch, Request, and Response with first class support for JSON objects.
16 lines (15 loc) • 822 B
TypeScript
export declare type JSONBodyInit = BodyInit | any;
export declare type JSONRequestInit = {
body?: JSONBodyInit | null;
} & Omit<RequestInit, 'body'>;
export declare class JSONRequest extends Request {
static contentType: string;
static accept: string;
constructor(input: RequestInfo | URL, init?: JSONRequestInit, replacer?: Parameters<typeof JSON.stringify>[1], space?: Parameters<typeof JSON.stringify>[2]);
}
export declare class JSONResponse extends Response {
static contentType: string;
constructor(body?: JSONBodyInit | null, init?: ResponseInit, replacer?: Parameters<typeof JSON.stringify>[1], space?: Parameters<typeof JSON.stringify>[2]);
}
export declare function jsonFetch(...args: ConstructorParameters<typeof JSONRequest>): Promise<Response>;
export * from './search-params-url.js';