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.

19 lines (18 loc) 551 B
/* * */ import { HttpException } from '@tmlmobilidade/consts'; /** * Fetches data from a URL using the SWR fetcher function without authentication. * @param url - The URL to fetch from * @returns Promise resolving to the fetched data * @example * ```ts * const data = await standardSwrFetcher('/api/users/123'); * ``` */ export const standardSwrFetcher = async (url) => { const res = await fetch(url, { credentials: 'omit' }); if (!res.ok) { throw new HttpException(res.status, res.statusText); } return res.json(); };