From 770def4d1bf14caeed1c609992f44963807b6f44 Mon Sep 17 00:00:00 2001 From: Garrett Date: Mon, 9 Oct 2023 15:38:15 -0700 Subject: [PATCH] Fix commoners --- package-lock.json | 8 ++++---- package.json | 2 +- src/frontend/main.ts | 16 +++++++--------- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3314fee..c2978a7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,7 +21,7 @@ "@commoners/bluetooth": "0.0.0", "@commoners/local-services": "0.0.0", "@commoners/serial": "0.0.0", - "commoners": "0.0.20" + "commoners": "0.0.21" } }, "node_modules/@ampproject/remapping": { @@ -4624,9 +4624,9 @@ } }, "node_modules/commoners": { - "version": "0.0.20", - "resolved": "https://registry.npmjs.org/commoners/-/commoners-0.0.20.tgz", - "integrity": "sha512-voLjPzsNANxShWFLuvPLFHbWbJBVU3DIqAfWSwhT7F1JZO72d4ey+ilPA+s/7YDfZQU0HuRYQ40vKD8fGVpVnA==", + "version": "0.0.21", + "resolved": "https://registry.npmjs.org/commoners/-/commoners-0.0.21.tgz", + "integrity": "sha512-T0oEvopnoz7/ZAUI6aGfQYQ9PKlAXvi/KTl7Rh2Rs+guJDu9grTEk2HhjHBNG91feSpJ5eT8c2BNV1FOIL3Now==", "dev": true, "dependencies": { "@electron-toolkit/tsconfig": "^1.0.1", diff --git a/package.json b/package.json index a16f6fd..75f89ab 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,6 @@ "@commoners/bluetooth": "0.0.0", "@commoners/serial": "0.0.0", "@commoners/local-services": "0.0.0", - "commoners": "0.0.20" + "commoners": "0.0.21" } } diff --git a/src/frontend/main.ts b/src/frontend/main.ts index de27ce3..1ca446f 100644 --- a/src/frontend/main.ts +++ b/src/frontend/main.ts @@ -62,7 +62,6 @@ const onData = (data: any) => { // Remote API Tests (Basic Fetch Commands) if (COMMONERS.services.remote && COMMONERS.services.dynamic) { - try { const remoteAPI = new URL('/users', COMMONERS.services.remote.url) const dynamicAPI = new URL('/users', COMMONERS.services.dynamic.url) @@ -71,14 +70,14 @@ if (COMMONERS.services.remote && COMMONERS.services.dynamic) { fetch(remoteAPI) .then(response => response.json()) .then(json => onData({source: 'Remote', command: 'users', payload: json.length})) + .catch(e => console.error('Failed to request from remote server', e)) fetch(dynamicAPI) .then(response => response.json()) .then(json => onData({source: `Dynamic = ${COMMONERS.MODE[0].toUpperCase() + COMMONERS.MODE.slice(1)}`, command: 'users', payload: json.length})) + .catch(e => console.error('Failed to request from dynamic server', e)) }) - } catch (e) { - console.error('Remote URLs not configured') - } + } @@ -116,11 +115,10 @@ if (COMMONERS.services.python) { const pythonUrl = new URL(COMMONERS.services.python.url) // Equivalent to commoners://python setTimeout(async () => { - try { - fetch(new URL('version', pythonUrl)).then(res => res.json()).then(payload => onData({ source: 'Python', command: 'version', payload })); - } catch (e) { - console.error('Failed to connect to Python server', e) - } + fetch(new URL('version', pythonUrl)) + .then(res => res.json()) + .then(payload => onData({ source: 'Python', command: 'version', payload })) + .catch(e => console.error('Failed to request from Python server', e)) }) }