| 47 | } |
| 48 | |
| 49 | async function processResponse(response: Response) { |
| 50 | const payload = await response.json(); |
| 51 | if (!response.ok) { |
| 52 | if (response.status === 401) { |
| 53 | // Force logout user and reload the page if Unauthorized |
| 54 | AuthStore.clear(); |
| 55 | queryClient.clear(); |
| 56 | window.location.reload(); |
| 57 | } |
| 58 | throw new Error( |
| 59 | typeof payload.error.messageI18n !== "undefined" ? payload.error.messageI18n : payload.error.message, |
| 60 | ); |
| 61 | } |
| 62 | return camelizeKeys(payload) as any; |
| 63 | } |
| 64 | |
| 65 | interface GetArgs { |
| 66 | url: string; |