Files
CityExplorer/api/locations.jsx

32 lines
770 B
JavaScript

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;
}
}