Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default async function getRoutePolyline (start: LonLatC, end: LonLatC) {
const startPoint = lonlat.toLatFirstString(start)
const endPoint = lonlat.toLatFirstString(end)
const response = await fetch(`${GRAPHHOPPER_API_URL}?key=${process.env.GRAPHHOPPER_API_KEY || ''}&point=${startPoint}&point=${endPoint}&instructions=false`)
const json = await response.json()
return decodePolyline(json.paths[0].points).map(c => ([c[1], c[0]])) // [lat,lon] -> [lon,lat]
}
export default async function getRoutePolyline (start: LonLatC, end: LonLatC) {
const startPoint = lonlat.toLatFirstString(start)
const endPoint = lonlat.toLatFirstString(end)
const response = await fetch(`${GRAPHHOPPER_API_URL}?key=${process.env.GRAPHHOPPER_API_KEY || ''}&point=${startPoint}&point=${endPoint}&instructions=false`)
const json = await response.json()
return decodePolyline(json.paths[0].points).map(c => ([c[1], c[0]])) // [lat,lon] -> [lon,lat]
}
.reply(200, (uri, body) => {
expect(uri.indexOf(lonlat.toLatFirstString(start)) > -1).toBeTruthy()
expect(uri.indexOf(lonlat.toLatFirstString(end)) > -1).toBeTruthy()
return mockResponse
})
.reply(200, (uri, body) => {
expect(uri.indexOf(lonlat.toLatFirstString(start)) > -1).toBeTruthy()
expect(uri.indexOf(lonlat.toLatFirstString(end)) > -1).toBeTruthy()
return mockResponse
})