Commit 97b3d0fe authored by Bertrand PINEL's avatar Bertrand PINEL
Browse files

Take into account Colin and Nicolas remark from Blog post

parent d87b237d
......@@ -41,11 +41,11 @@ export default class MapboxWsService extends Service {
"Access-Control-Allow-Origin": "*"
}
});
if (response.status === 200 && response.data.code === 'Ok') {
return { coords: response.data.routes[0].geometry.coordinates, dist: response.data.routes[0].distance };
} else {
return { coords: [], dist: 0};
}
if (response.status !== 200 && response.data.code !== 'Ok') {
return { coords: [], dist: 0};
}
return { coords: response.data.routes[0].geometry.coordinates, dist: response.data.routes[0].distance };
}
async optimize(profile, coord1, coord2) {
......@@ -61,11 +61,10 @@ export default class MapboxWsService extends Service {
"Access-Control-Allow-Origin": "*"
}
});
if (response.status === 200 && response.data.code === 'Ok') {
return response.data.trips[0].geometry.coordinates;
} else {
return [];
if (response.status !== 200 || response.data.code !== 'Ok') {
return [];
}
return response.data.trips[0].geometry.coordinates;
}
headers() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment