Use query strings to pass the start/destination

This commit is contained in:
rui hildt 2020-02-09 17:57:50 +01:00
parent f4c8b6e75c
commit d3097c565f

View File

@ -6,14 +6,20 @@ const Cities = require('../models/citiesModel');
const searchPath = require('../../helpers/dijkstra_algo');
router.get('', async (req, res) => {
const { start_city_id, end_city_id } = req.body;
const { start_city_id, end_city_id } = req.query;
console.log(typeof start_city_id)
start = Math.floor(start_city_id);
end = Math.floor(end_city_id);
console.log(start, end)
try {
const cities = await Cities.getCities();
const roads = await Roads.getRoads();
let { path, distance } = searchPath(cities, roads, start_city_id, end_city_id);
let { path, distance } = searchPath(cities, roads, start, end);
const formatedPath = formatPath(path, cities)
console.log(path)
let response = { path: formatedPath, distance }