- Neuer Endpunkt `updateBereich.js` für die Aktualisierung von Bereichskoordinaten per PUT-Request. - Utility-Funktion `updateBereichUtil.js` hinzugefügt, um API-Aufrufe für Bereichs-Updates im Frontend zu kapseln. - Fehler bei der URL in `updateBereichUtil.js` behoben, um sicherzustellen, dass die Koordinaten korrekt aktualisiert werden. - Verbesserte Fehlerbehandlung und Logging zur Debug-Unterstützung.
28 lines
711 B
JavaScript
28 lines
711 B
JavaScript
export const updateLocation = async (idLocation, idMap, newCoords) => {
|
|
try {
|
|
const response = await fetch("/api/talas_v5_DB/bereich/updateBereich", {
|
|
method: "PUT",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
body: JSON.stringify({
|
|
idLocation,
|
|
idMap,
|
|
x: newCoords.x,
|
|
y: newCoords.y,
|
|
}),
|
|
});
|
|
|
|
if (!response.ok) {
|
|
throw new Error("Fehler beim Aktualisieren der Koordinaten");
|
|
}
|
|
|
|
const data = await response.json();
|
|
console.log("Koordinaten erfolgreich aktualisiert:", data);
|
|
return data;
|
|
} catch (error) {
|
|
console.error("Fehler beim Aufruf von updateLocation:", error);
|
|
throw error;
|
|
}
|
|
};
|