datasquirel/dist/client/fetch/index.d.ts
Benjamin Toby 7e8bb37c09 Updates
2025-07-05 14:59:30 +01:00

37 lines
837 B
TypeScript

type FetchApiOptions<T extends {
[k: string]: any;
} = {
[k: string]: any;
}> = {
method: "POST" | "GET" | "DELETE" | "PUT" | "PATCH" | "post" | "get" | "delete" | "put" | "patch";
body?: T | string;
headers?: FetchHeader;
};
type FetchHeader = HeadersInit & {
[key: string]: string | null;
};
export type FetchApiReturn = {
success: boolean;
payload: any;
msg?: string;
[key: string]: any;
};
/**
* # Fetch API
*/
export default function fetchApi<T extends {
[k: string]: any;
} = {
[k: string]: any;
}, R extends any = any>(url: string, options?: FetchApiOptions<T>, csrf?: boolean,
/**
* Key to use to grab local Storage csrf value.
*/
localStorageCSRFKey?: string,
/**
* Key with which to set the request header csrf
* value
*/
csrfHeaderKey?: string): Promise<R>;
export {};