* Add lint-fix npm target * Sync eslint+plugins with backend * Add prettier * Ignore no-explicit-any lint rule for now * Silence eslint react warning * Format frontend via prettier * Lint frontend. --------- Co-authored-by: antanst <>
20 lines
541 B
TypeScript
20 lines
541 B
TypeScript
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.'
|
|
);
|
|
(error as any).info = errorData;
|
|
(error as any).status = response.status;
|
|
throw error;
|
|
}
|
|
|
|
return response.json();
|
|
};
|