mirror of
https://github.com/sussy-code/providers.git
synced 2026-04-19 07:32:08 +00:00
28 lines
658 B
TypeScript
28 lines
658 B
TypeScript
/**
|
|
* This file is a very relaxed definition of the fetch api
|
|
* Only containing what we need for it to function.
|
|
*/
|
|
|
|
export type FetchOps = {
|
|
headers: Record<string, string>;
|
|
method: string;
|
|
body: any;
|
|
credentials?: 'include' | 'same-origin' | 'omit';
|
|
};
|
|
|
|
export type FetchHeaders = {
|
|
get(key: string): string | null;
|
|
set(key: string, value: string): void;
|
|
};
|
|
|
|
export type FetchReply = {
|
|
text(): Promise<string>;
|
|
json(): Promise<any>;
|
|
extraHeaders?: FetchHeaders;
|
|
extraUrl?: string;
|
|
headers: FetchHeaders;
|
|
url: string;
|
|
status: number;
|
|
};
|
|
|
|
export type FetchLike = (url: string, ops?: FetchOps | undefined) => Promise<FetchReply>;
|