@tmlmobilidade/utils 20250828.1159.48 → 20250828.1342.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -73,3 +73,13 @@ export declare function uploadFile<T>(url: string, file: File): Promise<HttpResp
73
73
  * ```
74
74
  */
75
75
  export declare const swrFetcher: <T>(url: string) => Promise<T>;
76
+ /**
77
+ * Fetches data from a URL using the SWR fetcher function without authentication.
78
+ * @param url - The URL to fetch from
79
+ * @returns Promise resolving to the fetched data
80
+ * @example
81
+ * ```ts
82
+ * const data = await standardSwrFetcher('/api/users/123');
83
+ * ```
84
+ */
85
+ export declare const standardSwrFetcher: <T>(url: string) => Promise<T>;
package/dist/src/http.js CHANGED
@@ -140,3 +140,19 @@ export const swrFetcher = async (url) => {
140
140
  }
141
141
  return data.data;
142
142
  };
143
+ /**
144
+ * Fetches data from a URL using the SWR fetcher function without authentication.
145
+ * @param url - The URL to fetch from
146
+ * @returns Promise resolving to the fetched data
147
+ * @example
148
+ * ```ts
149
+ * const data = await standardSwrFetcher('/api/users/123');
150
+ * ```
151
+ */
152
+ export const standardSwrFetcher = async (url) => {
153
+ const res = await fetch(url, { credentials: 'omit' });
154
+ if (!res.ok) {
155
+ throw new HttpException(res.status, res.statusText);
156
+ }
157
+ return res.json();
158
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmlmobilidade/utils",
3
- "version": "20250828.1159.48",
3
+ "version": "20250828.1342.43",
4
4
  "author": "João de Vasconcelos & Jusi Monteiro",
5
5
  "license": "AGPL-3.0-or-later",
6
6
  "homepage": "https://github.com/tmlmobilidade/services#readme",