I am trying to send a number with a comma through JSON to save them in a MySQL database through a api rest created in node js.
Endpoint code
router.post('/', (req, res) => {
const sensorData = {
id: null,
temperatura: req.body.temperatura,
humedad: req.body.humedad,
indice_calor: req.body.indice_calor,
fecha: null,
};
Sensor.insertMetric(sensorData, (err, data) => {
if(data && data.insertId){
res.status(200).json({
success: true,
data: data
});
} else{
res.status(500).json({
success: false
});
}
});
JSON that sent
{
"temperatura": 2.3,
"humedad": 2.3,
"indice_calor": 2.3
}
However, in the database the values are stored as 0.99