From 13669074cf11c6899c54fc1b77af24b89455cb42 Mon Sep 17 00:00:00 2001 From: Mal Wood-Santoro Date: Fri, 21 Jan 2022 14:04:44 -0800 Subject: [PATCH] Catch 'No Route found' response (#278) * catch No Route response * remove console.log * add inline comment * update comment * fix linting issues --- src/actions/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/actions/index.js b/src/actions/index.js index 39fd53d..71fabaa 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -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));