So I’m making a Real-time Telemetry WebApp for tracking data from a car. I’ am using React for frontend and Node.js for backend. It works like this. A device sends data to the webpage using the MQTT protocol. When the data is received on the web page, it is decoded, parsed and stored in the data base for further use.
My question is: What is the best way to store the data in the database? I’m using MySQL. For now I’m using a timer on the frontend that will mount/unmount the component so the POST request is triggered, but that is not a good solution because I need data to be stored when it’s received so what I need is some sort of “trigger” that will launch a POST request to store the data. I was thinking of using websockets but I have no idea how to make it work. I’m looking for tips or a better solution if there is any.