@prismicio/custom-types-client
Version:
JavaScript client to interact with the Prismic Custom Types API
38 lines (37 loc) • 1.17 kB
TypeScript
/**
* A universal API to make network requests. A subset of the `fetch()` API.
*/
export type FetchLike = (input: string, init?: RequestInitLike) => Promise<ResponseLike>;
/**
* An `AbortSignal` provided by an `AbortController`. This allows the network
* request to be cancelled if necessary.
*
* {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal}
*/
export type AbortSignalLike = any;
/**
* A subset of RequestInit properties to configure a `fetch()` request.
*/
export interface RequestInitLike extends Partial<Pick<RequestInit, "cache">> {
method?: "GET" | "POST" | "DELETE";
body?: string;
/**
* An object literal to set the `fetch()` request's headers.
*/
headers?: Record<string, string>;
/**
* An AbortSignal to set the `fetch()` request's signal.
*
* See:
* [https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)
*/
signal?: AbortSignalLike;
}
/**
* The minimum required properties from Response.
*/
export interface ResponseLike {
status: number;
json(): Promise<any>;
text(): Promise<any>;
}