link geändert für prio API
This commit is contained in:
29
pages/api/prio.js
Normal file
29
pages/api/prio.js
Normal file
@@ -0,0 +1,29 @@
|
||||
import getPool from "../../utils/mysqlPool";
|
||||
|
||||
export default async function handler(req, res) {
|
||||
// Nur GET-Anfragen zulassen
|
||||
if (req.method !== "GET") {
|
||||
return res.status(405).json({ error: "Methode nicht erlaubt" });
|
||||
}
|
||||
|
||||
const pool = getPool(); // Singleton-Pool verwenden
|
||||
let connection;
|
||||
|
||||
try {
|
||||
// Verbindung abrufen
|
||||
connection = await pool.getConnection();
|
||||
|
||||
// SQL-Query
|
||||
const query = "SELECT idprio, level, name, color FROM prio";
|
||||
const [results] = await connection.query(query);
|
||||
|
||||
// Erfolgreiche Antwort
|
||||
res.status(200).json(results);
|
||||
} catch (error) {
|
||||
console.error("Fehler beim Abrufen der API:", error.message); // Mehr Details
|
||||
res.status(500).json({ error: "Interner Serverfehler" });
|
||||
} finally {
|
||||
// Verbindung freigeben
|
||||
if (connection) connection.release();
|
||||
}
|
||||
}
|
||||
@@ -37,8 +37,8 @@ export const createAndSetDevices = async (systemId, setMarkersFunction, GisSyste
|
||||
const getIdSystemAndAllowValueMap = new Map(GisSystemStatic.map((system) => [system.IdSystem, system.Allow]));
|
||||
|
||||
if (jsonResponse.Points && statusResponse.Statis) {
|
||||
//console.log("jsonResponse.Points: ", jsonResponse.Points);
|
||||
//console.log("statusResponse.Statis: ", statusResponse.Statis);
|
||||
console.log("jsonResponse.Points: ", jsonResponse.Points);
|
||||
console.log("statusResponse.Statis: ", statusResponse.Statis);
|
||||
localStorage.setItem("jsonResponse.Points", JSON.stringify(jsonResponse.Points));
|
||||
localStorage.setItem("statusResponse.Statis", JSON.stringify(statusResponse.Statis));
|
||||
const statisMap = new Map(statusResponse.Statis.map((s) => [s.IdLD, s]));
|
||||
|
||||
Reference in New Issue
Block a user