From e316d3a6086e9c4a53eac387fc88ec026c8c8674 Mon Sep 17 00:00:00 2001 From: Julien Oculi Date: Wed, 26 Jun 2024 14:34:00 +0200 Subject: [PATCH] feat(client): :sparkles: add feedback message on connection success --- client/src/utils.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/src/utils.js b/client/src/utils.js index 3316387..be7afb5 100644 --- a/client/src/utils.js +++ b/client/src/utils.js @@ -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}`, {