tududi/app/frontend/utils/fetcher.ts
Chris Veleris dfcb97a355 Move to React
Add .gitignore

Removed node_modules from previous commit

Fix task modes

Fix task modes

Fix task modes

Remove node_modules

Update basic task modal

Add notes functionality

Improve UI

Setup views

Add scopes

Fix projects layout

Restructure

Fix rest of the UI issues

Cleanup old views

Add .env to .gitignore
2024-10-25 21:03:43 +03:00

21 lines
544 B
TypeScript

// src/utils/fetcher.ts
export const fetcher = async (url: string) => {
const response = await fetch(url, {
credentials: 'include',
headers: {
'Accept': 'application/json',
},
});
if (!response.ok) {
const errorData = await response.json();
const error = new Error(errorData.error || 'An error occurred while fetching the data.');
// Attach extra info to the error object.
(error as any).info = errorData;
(error as any).status = response.status;
throw error;
}
return response.json();
};