2020-10-07 21:27:30 +00:00
|
|
|
import Axios from './API';
|
2020-02-09 23:12:39 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|