docs: ui/web/README.md: fix link, take 2
[e-mobility-charging-stations-simulator.git] / ui / web / src / composables / UIClient.ts
index b78d6a0b7fc2ed9dd41d09509ee26c953ac3114e..387d73d27529bfaf91e25f068bd9612ce53fb33c 100644 (file)
@@ -145,13 +145,12 @@ export class UIClient {
     data: RequestPayload,
   ): Promise<ResponsePayload> {
     return new Promise<ResponsePayload>((resolve, reject) => {
-      const uuid = crypto.randomUUID();
-      const msg = JSON.stringify([uuid, command, data]);
-
       if (this.ws.readyState !== WebSocket.OPEN) {
         this.openWS();
       }
       if (this.ws.readyState === WebSocket.OPEN) {
+        const uuid = crypto.randomUUID();
+        const msg = JSON.stringify([uuid, command, data]);
         const sendTimeout = setTimeout(() => {
           this.deleteResponseHandler(uuid);
           return reject(new Error(`Send request '${command}' message timeout`));