mirror of
https://github.com/speatzle/nfsense.git
synced 2025-06-28 07:19:37 +00:00
Improved API Logging
- Log now includes method, parameters and the promise object
This commit is contained in:
parent
7e7cff371f
commit
55bdaf915c
1 changed files with 6 additions and 5 deletions
|
@ -15,17 +15,18 @@ export function setup(_UnauthorizedCallback: () => void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function apiCall(method: string, params: Record<string, any>): Promise<any>{
|
export async function apiCall(method: string, params: Record<string, any>): Promise<any>{
|
||||||
console.debug('Starting API Call...');
|
|
||||||
try {
|
try {
|
||||||
const result = await jrpc.call(method, params);
|
const pResult = jrpc.call(method, params);
|
||||||
console.debug('api call result', result);
|
console.debug('[API] Calling ', method, params, pResult);
|
||||||
|
const result = await pResult;
|
||||||
|
console.debug('[API] Response', method, result);
|
||||||
return { Data: result, Error: null};
|
return { Data: result, Error: null};
|
||||||
} catch (ex: any){
|
} catch (ex: any){
|
||||||
if (ex.code === 401) {
|
if (ex.code === 401) {
|
||||||
UnauthorizedCallback();
|
UnauthorizedCallback();
|
||||||
} else {
|
} else {
|
||||||
$toast.error(`${method }: ${ ex.message}`);
|
$toast.error(`${method }: ${ ex.message}`);
|
||||||
console.debug('api call epic fail', ex);
|
console.debug('[API] Error ', method, ex);
|
||||||
}
|
}
|
||||||
return { Data: null, Error: ex};
|
return { Data: null, Error: ex};
|
||||||
}
|
}
|
||||||
|
@ -62,7 +63,7 @@ export async function checkAuthentication() {
|
||||||
if (last_hash !== response.data.commit_hash) {
|
if (last_hash !== response.data.commit_hash) {
|
||||||
console.log('Detected New Backend Version, Reloading...');
|
console.log('Detected New Backend Version, Reloading...');
|
||||||
window.localStorage.removeItem('commit_hash');
|
window.localStorage.removeItem('commit_hash');
|
||||||
window.location.reload();
|
// window.location.reload();
|
||||||
}
|
}
|
||||||
} else window.localStorage.setItem('commit_hash', response.data.commit_hash);
|
} else window.localStorage.setItem('commit_hash', response.data.commit_hash);
|
||||||
return {auth: 2, error: null};
|
return {auth: 2, error: null};
|
||||||
|
|
Loading…
Add table
Reference in a new issue