// /pages/api/talas5/location_device.js import getPool from "../../../utils/mysqlPool"; // Import Singleton-Pool // API-Handler export default async function handler(req, res) { const pool = getPool(); // Singleton-Pool verwenden let connection; try { // SQL-Query, um die Geräteinformationen aus location_device und devices zu erhalten const sql = ` SELECT ld.idLD, ld.iddevice, ld.name, d.idsystem_typ FROM location_device ld JOIN devices d ON ld.iddevice = d.iddevice ORDER BY ld.name `; connection = await pool.getConnection(); // Führe die Abfrage durch const [results] = await connection.query(sql); if (!results.length) { return res.status(404).json({ error: "Keine Geräte gefunden" }); } // Geben Sie die Daten zurück res.status(200).json(results); } catch (error) { // Loggen Sie den Fehler und geben Sie ihn zurück console.error("Fehler beim Abrufen der Geräteinformationen:", error); res.status(500).json({ error: "Fehler beim Abrufen der Geräteinformationen" }); } finally { if (connection) connection.release(); } }