Im trying to add directions between one point and another but i only get the response that two points need to be specified while i think i did it the right way, searched on the issue but couldnt find a response so my bad in advance if theres a similar post already, here is my code i cant see where the fetch goes wrong
const query = new URLSearchParams({
profile: ‘foot’,
points: [
[longitude, latitude],
[55.60932713633075, 12.993716534967398]
],
key: mykey
}).toString();
fetch(`https://graphhopper.com/api/1/route?${query}`, { method: 'GET' })
.then(resp => resp.json())
.then(data => {
if (data.paths && data.paths.length > 0) {
const routeCoordinates = data.paths[0].points.coordinates.map(coord => L.latLng(coord[1], coord[0]));
L.polyline(routeCoordinates, { color: 'blue' }).addTo(map); // Draw directions on the map
} else {
console.log(data);
console.log("No directions found.");
}
})