Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

476
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda