docs: ui/web/README.md: fix link, take 2
[e-mobility-charging-stations-simulator.git] / ui / web / src / composables / UIClient.ts
index 89db2302c81e1dec901965efeb4c6444196a5d30..387d73d27529bfaf91e25f068bd9612ce53fb33c 100644 (file)
@@ -144,15 +144,13 @@ export class UIClient {
     command: ProcedureName,
     data: RequestPayload,
   ): Promise<ResponsePayload> {
-    let uuid: string;
     return new Promise<ResponsePayload>((resolve, reject) => {
-      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`));