feat(client): ✨ add feedback message on connection success
This commit is contained in:
parent
491d7ea1ab
commit
e316d3a608
|
@ -15,7 +15,7 @@ export async function sendCommand(command, value) {
|
||||||
const endpoint = getEndpoint()
|
const endpoint = getEndpoint()
|
||||||
const url = new URL(`/get?command=${command}&value=${value}`, endpoint)
|
const url = new URL(`/get?command=${command}&value=${value}`, endpoint)
|
||||||
const response = await fetch(url, {
|
const response = await fetch(url, {
|
||||||
mode: 'no-cors'
|
mode: 'no-cors',
|
||||||
})
|
})
|
||||||
const text = await response.text()
|
const text = await response.text()
|
||||||
console.log(text)
|
console.log(text)
|
||||||
|
@ -58,9 +58,9 @@ export async function testEndpoint(endpoint) {
|
||||||
try {
|
try {
|
||||||
const url = new URL('/get', endpoint)
|
const url = new URL('/get', endpoint)
|
||||||
const response = await fetch(url, {
|
const response = await fetch(url, {
|
||||||
mode: 'no-cors'
|
mode: 'no-cors',
|
||||||
})
|
})
|
||||||
if (response.ok) return
|
if (response.ok || response.status === 0) alert('Connection réussie')
|
||||||
} catch (cause) {
|
} catch (cause) {
|
||||||
alert(`Impossible de joindre l'adresse "${endpoint}"`)
|
alert(`Impossible de joindre l'adresse "${endpoint}"`)
|
||||||
throw new Error(`unable to connect to robot at ${endpoint}`, {
|
throw new Error(`unable to connect to robot at ${endpoint}`, {
|
||||||
|
|
Loading…
Reference in a new issue