feat(client): add feedback message on connection success

This commit is contained in:
Julien Oculi 2024-06-26 14:34:00 +02:00
parent 491d7ea1ab
commit e316d3a608

View file

@ -15,7 +15,7 @@ export async function sendCommand(command, value) {
const endpoint = getEndpoint()
const url = new URL(`/get?command=${command}&value=${value}`, endpoint)
const response = await fetch(url, {
mode: 'no-cors'
mode: 'no-cors',
})
const text = await response.text()
console.log(text)
@ -58,9 +58,9 @@ export async function testEndpoint(endpoint) {
try {
const url = new URL('/get', endpoint)
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) {
alert(`Impossible de joindre l'adresse "${endpoint}"`)
throw new Error(`unable to connect to robot at ${endpoint}`, {