Skip to content

Commit

Permalink
Catch 'No Route found' response (#278)
Browse files Browse the repository at this point in the history
* catch No Route response

* remove console.log

* add inline comment

* update comment

* fix linting issues
  • Loading branch information
Mal Wood-Santoro authored Jan 21, 2022
1 parent 7bdc5ca commit 1366907
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ function fetchDirections() {
dispatch(setDirections([]));
return dispatch(setError(data.error));
}

// Catch no route responses and display message to user
if (data.message === 'No route found') {
return dispatch(setError('No route found'));
}

dispatch(setError(null));
if (!data.routes[routeIndex]) dispatch(setRouteIndex(0));
Expand Down

0 comments on commit 1366907

Please sign in to comment.