modified: server.js

This commit is contained in:
IrisVega 2024-07-20 17:45:09 +08:00
parent d305f0e03c
commit 3d372000c8

View File

@ -60,12 +60,12 @@ function getLatestSensorData(callback) {
callback({ error: 'Error fetching latest sensor data' }); callback({ error: 'Error fetching latest sensor data' });
return; return;
} }
const data = results[0];
const timestamps = data.map(row => new Date(row.timestamp).toISOString().slice(0, 19).replace('T', ' ')); const timestamps = results.map(row => new Date(row.timestamp).toISOString().slice(0, 19).replace('T', ' '));
const temperatures = data.map(row => row.temperature); const temperatures = results.map(row => row.temperature);
const humidities = data.map(row => row.humidity); const humidities = results.map(row => row.humidity);
const co2 = data.map(row => row.co2); const co2 = results.map(row => row.co2);
const pressure = data.map(row => row.pressure); const pressure = results.map(row => row.pressure);
callback({ callback({
timestamps, timestamps,
temperatures, temperatures,