Prepair: With Recoil atom pass current poi data from MapComponent to poiUpdateModal.js when mouse over
This commit is contained in:
33
pages/api/locationDevices.js
Normal file
33
pages/api/locationDevices.js
Normal file
@@ -0,0 +1,33 @@
|
||||
// API in /api/locationDevices.js
|
||||
import mysql from 'mysql';
|
||||
|
||||
const dbConfig = {
|
||||
host: process.env.DB_HOST,
|
||||
user: process.env.DB_USER,
|
||||
password: process.env.DB_PASSWORD,
|
||||
database: process.env.DB_NAME,
|
||||
port: process.env.DB_PORT,
|
||||
};
|
||||
|
||||
const connection = mysql.createConnection(dbConfig);
|
||||
connection.connect((err) => {
|
||||
if (err) {
|
||||
console.error("Fehler beim Verbinden:", err.stack);
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
export default function handler(req, res) {
|
||||
if (req.method !== "GET") {
|
||||
return res.status(405).json({ error: "Nur GET Methode erlaubt" });
|
||||
}
|
||||
|
||||
const query = "SELECT * FROM location_device WHERE iddevice = 160";
|
||||
connection.query(query, (error, results) => {
|
||||
if (error) {
|
||||
console.error("Fehler beim Abrufen der Geräteinformationen:", error);
|
||||
return res.status(500).json({ error: "Fehler beim Abrufen der Geräteinformationen" });
|
||||
}
|
||||
res.json(results);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user