@tmlmobilidade/utils 20250828.1000.31 → 20250828.1338.25
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.
- package/dist/src/http.d.ts +10 -0
- package/dist/src/http.js +16 -0
- package/package.json +1 -1
package/dist/src/http.d.ts
CHANGED
|
@@ -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