get list of location and get location by id

This commit is contained in:
2025-05-13 15:55:20 +02:00
parent c242f92745
commit 395d68a31a
5 changed files with 344 additions and 10 deletions

31
api/locations.jsx Normal file
View File

@@ -0,0 +1,31 @@
import axios from "axios";
const API_URL = "http://192.168.7.188:9000";
export async function listLocations() {
try {
const response = await axios.get(`${API_URL}/locations/all`);
if (!response) {
throw new Error("No locations found");
}
return response.data;
} catch (error) {
console.error("Error fetching locations:", error);
throw error;
}
}
export async function getLocation(id) {
try {
const location = await axios.get(`${API_URL}/locations/${id}`);
if (!location) {
throw new Error("Location not found");
}
return location.data;
} catch (error) {
console.error("Error fetching location:", error);
throw error;
}
}