Websocket Integration - How to get WebSocket data stored into entity to show in dataGrid

Hi , I'm new to Mendix. Want to get some sample to integrate Websocket message to display in a grid. The use case is to read continuous data from Websocket and display into dataGrid. Steps I followed: Added nano flow with Java Script action node which has script to consume messages from websocket Created Entity mx.data.create() which stores data onto object try to save(mx.data.save) --> getting error saying no such method try to commit (mx.data.commit) instead of save not able to pass the object. If i try not to save/Commit , I'm not able to get this entity into datagird. Code is as follow:   Can someone help please.  // BEGIN EXTRA CODE // END EXTRA CODE   /** * @returns {Promise.<string>} */ export async function WSclient() { // BEGIN USER CODE // Define the WebSocket URL const websocketUrl = 'ws://localhost:8765/websocket'; // Replace with your WebSocket server URL // const mx = require("mendixclient"); // Function to handle WebSocket events function handleWebSocket() { // Create a new WebSocket connection const socket = new WebSocket(websocketUrl);   // Handle WebSocket events socket.onopen = function(event) { console.log("WebSocket connection is open"); };   socket.onmessage = function(event) { const receivedData = event.data; console.log("Received WebSocket data: " + receivedData);   // Assuming "MyFirstModule.WebSocketMessage" is an entity in your Mendix app const entity = "MyFirstModule.WebSocketMessage"; const messageContent = receivedData;   // Create an object and set its properties mx.data.create({ entity: entity, callback: function(messageContentObj) { messageContentObj.set("MessageContent", messageContent); //obj.set("Timestamp", new Date()); console.log("WebSocket message created*****" + messageContent); }, error: function(error) { console.error("Error creating WebSocket message object: " + error.message); } }); };   socket.onclose = function(event) { console.log("WebSocket connection is closed"); };   socket.onerror = function(event) { console.error("WebSocket error: " + event.message); }; }   // Call the WebSocket handling function handleWebSocket();   // END USER CODE }  
0 answers