diff --git a/app/services/mapbox-ws.js b/app/services/mapbox-ws.js index 94867d5e1fd0efe708d85f565b88986e0e3078d1..a9fc8e6d64766c61fa1bec6d6cf15110172e7bfa 100644 --- a/app/services/mapbox-ws.js +++ b/app/services/mapbox-ws.js @@ -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() {