Skip to content

Commit

Permalink
Fix commoners
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettmflynn committed Oct 9, 2023
1 parent 922746f commit 770def4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
16 changes: 7 additions & 9 deletions src/frontend/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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')
}

}


Expand Down Expand Up @@ -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))
})
}

Expand Down

0 comments on commit 770def4

Please sign in to comment.