UNPKG

@tmlmobilidade/utils

Version:

A collection of utility functions and helpers for the TML Mobilidade Go monorepo, providing common functionality for batching operations, caching, HTTP requests, object manipulation, permissions, and more.

42 lines (41 loc) 1.43 kB
export interface SwrFetcherOptions { /** * Whether to include credentials in the fetch operation. * @default 'include' */ credentials?: RequestInit['credentials']; /** * The URL to fetch from. */ url: string; /** * Whether to use the proper API response, where the response is an object with a data property. * If false, the response is assumed to be the data directly. * @default true */ useProperApiResponse?: boolean; } /** * Fetches data from a URL using the SWR fetcher function. * @param urlOrOptions The URL to fetch from or the options object. * @returns Promise resolving to the fetched data * @example * ```ts * // Fetch data from a URL * const data = await swrFetcher('/api/users/123'); * * // Fetch data from a URL with options * const data = await swrFetcher({ url: '/api/users/123', credentials: 'omit' }); * ``` */ export declare function swrFetcher<T>(urlOrOptions: string | SwrFetcherOptions): Promise<T>; /** * Fetches data from a URL using the SWR fetcher function. * @param urlOrOptions The URL to fetch from or the options object. * @returns Promise resolving to the fetched data * @deprecated Use `swrFetcher` with an options object instead. * ```ts * const data = await swrFetcher({ url: '/api/users/123', credentials: 'omit' }); * ``` */ export declare function unauthenticatedSwrFetcher<T>(url: string): Promise<T>;