// /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 and parameters const sql = "SELECT idLD, iddevice, name FROM location_device WHERE iddevice = ?"; const params = [160]; // Example parameter // Get a connection from the pool connection = await pool.getConnection(); // Execute the query const [results] = await connection.query(sql, params); // Check if results are empty if (!results.length) { return res.status(404).json({ error: "Keine Geräte gefunden" }); } // Respond with the results res.status(200).json(results); } catch (error) { // Log and return error 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(); } }