mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-02-12 09:08:32 +00:00
fix: don't load app config and user on every route change
This commit is contained in:
19
frontend/src/hooks.client.ts
Normal file
19
frontend/src/hooks.client.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import type { HandleClientError } from '@sveltejs/kit';
|
||||
import { AxiosError } from 'axios';
|
||||
|
||||
export const handleError: HandleClientError = async ({ error, message, status }) => {
|
||||
if (error instanceof AxiosError) {
|
||||
message = error.response?.data.error || message;
|
||||
status = error.response?.status || status;
|
||||
console.error(
|
||||
`Axios error: ${error.request.path} - ${error.response?.data.error ?? error.message}`
|
||||
);
|
||||
} else {
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
return {
|
||||
message,
|
||||
status
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user