Rename api/locations to api/readLocations and api/poiTyp to api/readPoiTyp
This commit is contained in:
@@ -332,7 +332,7 @@ const MapComponent = ({ locations, onLocationUpdate }) => {
|
||||
useEffect(() => {
|
||||
const fetchPoiTypData = async () => {
|
||||
try {
|
||||
const response = await fetch("/api/poiTyp");
|
||||
const response = await fetch("/api/readPoiTyp");
|
||||
const data = await response.json();
|
||||
setPoiTypData(data); // Daten im Recoil State speichern
|
||||
} catch (error) {
|
||||
|
||||
@@ -11,7 +11,7 @@ const ShowAddStationPopup = ({ map, latlng }) => {
|
||||
useEffect(() => {
|
||||
const fetchPoiTypData2 = async () => {
|
||||
try {
|
||||
const response = await fetch("/api/poiTyp");
|
||||
const response = await fetch("/api/readPoiTyp");
|
||||
const data = await response.json();
|
||||
setPoiTypData2(data);
|
||||
if (data && data.length > 0) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// pages/api/locations.js
|
||||
// pages/api/readLocations.js
|
||||
import mysql from "mysql";
|
||||
|
||||
|
||||
const dbConfig = {
|
||||
host: process.env.DB_HOST,
|
||||
user: process.env.DB_USER,
|
||||
@@ -11,7 +10,6 @@ const dbConfig = {
|
||||
};
|
||||
console.log("my dbconfig: ", dbConfig);
|
||||
export default function handler(req, res) {
|
||||
|
||||
const connection = mysql.createConnection(dbConfig);
|
||||
|
||||
connection.connect((err) => {
|
||||
@@ -27,18 +25,21 @@ export default function handler(req, res) {
|
||||
"SELECT idPoi, description, idPoiTyp, ST_AsText(position) AS position FROM poi",
|
||||
(error, results) => {
|
||||
if (error) {
|
||||
console.error("Fehler beim Abrufen der API",error);
|
||||
console.error("Fehler beim Abrufen der API", error);
|
||||
res.status(500).json({ error: "Fehler bei der Abfrage" });
|
||||
return;
|
||||
}
|
||||
|
||||
// Wichtig: Senden Sie die Antwort zurück
|
||||
res.status(200).json(results );
|
||||
console.log( "--------------- location.js ---------------","results in location.js : ",results, "---------------------- location.js end ---------------------------");
|
||||
res.status(200).json(results);
|
||||
console.log(
|
||||
"--------------- location.js ---------------",
|
||||
"results in location.js : ",
|
||||
results,
|
||||
"---------------------- location.js end ---------------------------"
|
||||
);
|
||||
connection.end();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// pages/api/poiTyp.js
|
||||
// pages/api/readPoiTyp.js
|
||||
import mysql from "mysql";
|
||||
|
||||
const dbConfig = {
|
||||
@@ -19,7 +19,7 @@ export default function Home() {
|
||||
});
|
||||
|
||||
const loadData = async () => {
|
||||
const response = await fetch("/api/locations");
|
||||
const response = await fetch("/api/readLocations");
|
||||
const data = await response.json();
|
||||
setLocations(data);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user