41 lines
878 B
JavaScript
41 lines
878 B
JavaScript
import Axios from './API';
|
|
|
|
export async function fetchRoads() {
|
|
try {
|
|
const { data } = await Axios.get(
|
|
`api/roads`
|
|
);
|
|
return data
|
|
} catch (error) {
|
|
console.error(error);
|
|
}
|
|
};
|
|
|
|
export async function fetchCities() {
|
|
try {
|
|
const { data } = await Axios.get(
|
|
`api/countries/1`
|
|
);
|
|
return data
|
|
} catch (error) {
|
|
console.error(error);
|
|
}
|
|
};
|
|
|
|
export async function getShortestPath(startingPointId, destinationID) {
|
|
try {
|
|
const response = await Axios.get(
|
|
`api/path`,
|
|
{
|
|
params: {
|
|
start_city_id: startingPointId,
|
|
end_city_id: destinationID
|
|
}
|
|
}
|
|
);
|
|
return response.data
|
|
} catch (error) {
|
|
console.error(error);
|
|
}
|
|
}
|