JSFiddle - React, Tailwind, and code Playground

JavaScript

WebSocket.prototype.oldSend = WebSocket.prototype.send;
WebSocket.prototype.send = function(data) {
     console.log("WS: sending data: " + data);
     console.log(this);
     WebSocket.prototype.oldSend.apply(this, [data]);
};

var data = "abc";

var ws = new WebSocket("wss://echo.websocket.org");
ws.onopen = function(evt) { ws.send(data); };
ws.onmessage = function(evt) { console.log(evt); ws.close(); };