Merge branch 'feature/dropdown-filter' into develop
This commit is contained in:
@@ -7,25 +7,27 @@ export default async function handler(req, res) {
|
||||
|
||||
let connection;
|
||||
try {
|
||||
// SQL-Query and parameters
|
||||
const sql = "SELECT idLD, iddevice, name FROM location_device WHERE iddevice = ?";
|
||||
const params = [160]; // Example parameter
|
||||
// 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
|
||||
`;
|
||||
|
||||
// Get a connection from the pool
|
||||
connection = await pool.getConnection();
|
||||
|
||||
// Execute the query
|
||||
const [results] = await connection.query(sql, params);
|
||||
// Führe die Abfrage durch
|
||||
const [results] = await connection.query(sql);
|
||||
|
||||
// Check if results are empty
|
||||
if (!results.length) {
|
||||
return res.status(404).json({ error: "Keine Geräte gefunden" });
|
||||
}
|
||||
|
||||
// Respond with the results
|
||||
// Geben Sie die Daten zurück
|
||||
res.status(200).json(results);
|
||||
} catch (error) {
|
||||
// Log and return 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 {
|
||||
|
||||
Reference in New Issue
Block a user