dijkstra-frontend/src/components/requests.js

41 lines
885 B
JavaScript

import Axios from '../utils/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);
}
}