Use query strings to pass the start/destination
This commit is contained in:
parent
f4c8b6e75c
commit
d3097c565f
@ -6,14 +6,20 @@ const Cities = require('../models/citiesModel');
|
|||||||
const searchPath = require('../../helpers/dijkstra_algo');
|
const searchPath = require('../../helpers/dijkstra_algo');
|
||||||
|
|
||||||
router.get('', async (req, res) => {
|
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 {
|
try {
|
||||||
const cities = await Cities.getCities();
|
const cities = await Cities.getCities();
|
||||||
const roads = await Roads.getRoads();
|
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)
|
const formatedPath = formatPath(path, cities)
|
||||||
|
console.log(path)
|
||||||
|
|
||||||
let response = { path: formatedPath, distance }
|
let response = { path: formatedPath, distance }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user