mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-10 17:43:51 +00:00
Wrapped logic to perform HTTP requests with fetch into an HttpClient class
This commit is contained in:
@@ -1,10 +0,0 @@
|
||||
export const jsonFetch = (fetch: typeof window.fetch) => <T>(url: string, options?: RequestInit) => fetch(url, options)
|
||||
.then(async (resp) => {
|
||||
const parsed = await resp.json();
|
||||
|
||||
if (!resp.ok) {
|
||||
throw parsed; // eslint-disable-line @typescript-eslint/no-throw-literal
|
||||
}
|
||||
|
||||
return parsed as T;
|
||||
});
|
||||
Reference in New Issue
Block a user