From 5a6327052ca9fa6a9cd7997f14f0660ed19ea280 Mon Sep 17 00:00:00 2001 From: mehtix1 Date: Sat, 16 Nov 2024 01:21:33 +0330 Subject: [PATCH] Update index.html --- index.html | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index c66faa9..bb4973f 100644 --- a/index.html +++ b/index.html @@ -33,9 +33,23 @@

WebSocket and Webhook Example

let flag = event.data; console.log("Received message:", flag); - // Add the flag to the message queue - messageQueue.push(flag); - }; + // Check if the flag is greater than 0 + if (parseFloat(flag) > 0) { + // If flag is greater than 0, send POST request to Webhook + sendPostToWebhook(flag) + .then(() => { + console.log("POST request sent successfully!"); + }) + .catch((error) => { + console.error("Error sending POST request:", error); + }); + } else { + console.log("Flag is not greater than 0, not sending POST request."); + } + + // Add the flag to the message queue if needed + messageQueue.push(flag); +}; // Send POST requests at regular intervals (every 2 seconds) setInterval(() => {