Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

475
Vistas
How to send data from frontend to backend? - Node.js

I have a project where I have go-karts and I have users. Each user will get a go-kart, but for that I have to put both data sets in a database. The user is already in it, but I can't put the go-karts in because it's a separate file in the public folder.

My folder structure looks like this:

-contollers
    -auth.js (Here is the database code for the users)
-node_modules
-public
   -img
   -style
   -js
      -gokart.js (I would like to send one or two pieces of this data to the database)
 -routes
    -auth.js
    -pages.js
 -views
    -gokart.hbs
    -register.hbs
    -index.hbs
    -login.hbs
app.js

The go-kart file looks like this:

   var ros = new ROSLIB.Ros({

    url:'ws://10.0.2.15:9090'

});

ros.on('connection',function(){

    console.log("Connected to websocket server")

});

ros.on('error',function(){

    console.log("Error connecting to websocket server: ",error)

}); 

ros.on('close',function(){

    console.log("Connection to websocket server closed.")

});


var gokarts = new ROSLIB.Topic({

    ros:ros,

    name:"/dwm1001/tag5617",

    messageType:"dwm1001/anchor"

});


var myChart;

let canvas = document.getElementById('myChart');

let ctx = canvas.getContext('2d');


function init(){

    myChart = new Chart(ctx, {

        type: 'scatter',

        data: {

            datasets: [{

                label: 'GOKART moving',

                backgroundColor: "blue",
                
                data: [],

            }]

        },

        options: {

            responsive: false,

            aspectRatio: 1,
            
            maintainAspestRatio: true,

            scales: {

                xAxes: [{
                    
                    ticks:{

                        stepSize:2,

                        suggestedMax:18,

                    }

                }]

    ,            yAxes: [{

                    ticks:{
                        
                        stepSize:2,

                        suggestedMax:18,

                    }

                }]

            }

        }

    });

}



init();




gokarts.subscribe(function(message) {
   

    myChart.data.datasets[0].data.push({x:message.x.toFixed(2), y:message.y.toFixed(2);

    myChart.update();

});

I want to put the gokarts.name and gokart.messageType of the go-kart in a database.(I used mysql)

Thanks for the ideas!

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda