From 55bdaf915ca54b29b0e2350ae320d75838d6160b Mon Sep 17 00:00:00 2001 From: adro Date: Fri, 3 Nov 2023 17:26:11 +0100 Subject: [PATCH] Improved API Logging - Log now includes method, parameters and the promise object --- client/src/api.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/client/src/api.ts b/client/src/api.ts index 973d523..51752ed 100644 --- a/client/src/api.ts +++ b/client/src/api.ts @@ -15,17 +15,18 @@ export function setup(_UnauthorizedCallback: () => void) { } export async function apiCall(method: string, params: Record): Promise{ - console.debug('Starting API Call...'); try { - const result = await jrpc.call(method, params); - console.debug('api call result', result); + const pResult = jrpc.call(method, params); + console.debug('[API] Calling ', method, params, pResult); + const result = await pResult; + console.debug('[API] Response', method, result); return { Data: result, Error: null}; } catch (ex: any){ if (ex.code === 401) { UnauthorizedCallback(); } else { $toast.error(`${method }: ${ ex.message}`); - console.debug('api call epic fail', ex); + console.debug('[API] Error ', method, ex); } return { Data: null, Error: ex}; } @@ -62,7 +63,7 @@ export async function checkAuthentication() { if (last_hash !== response.data.commit_hash) { console.log('Detected New Backend Version, Reloading...'); window.localStorage.removeItem('commit_hash'); - window.location.reload(); + // window.location.reload(); } } else window.localStorage.setItem('commit_hash', response.data.commit_hash); return {auth: 2, error: null};