From 15cc6e00f3b127ca5a18049f5121f8643788d375 Mon Sep 17 00:00:00 2001 From: slowbackspace Date: Mon, 4 Mar 2019 19:03:07 +0100 Subject: [PATCH 1/2] handle response codes --- src/actions/WalletActions.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/actions/WalletActions.js b/src/actions/WalletActions.js index 063f548e..620d3ace 100644 --- a/src/actions/WalletActions.js +++ b/src/actions/WalletActions.js @@ -86,13 +86,21 @@ export const toggleSidebar = (): WalletAction => ({ export const fetchLocale = (locale: string): ThunkAction => (dispatch: Dispatch): void => { fetch(`./l10n/${locale}.json`) - .then(response => response.json()) + .then(response => { + if (response.ok) { + return response.json(); + } + throw Error(response.statusText); + }) .then(messages => { dispatch({ type: WALLET.SET_LANGUAGE, locale, messages, }); + }) + .catch(error => { + console.log(error); }); }; From 4757c71f45a806b8c9d07a9b648392095b5af5c7 Mon Sep 17 00:00:00 2001 From: slowbackspace Date: Tue, 5 Mar 2019 11:53:33 +0100 Subject: [PATCH 2/2] use console.error instead of console.log --- src/actions/WalletActions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/actions/WalletActions.js b/src/actions/WalletActions.js index 620d3ace..d44914a2 100644 --- a/src/actions/WalletActions.js +++ b/src/actions/WalletActions.js @@ -100,7 +100,7 @@ export const fetchLocale = (locale: string): ThunkAction => (dispatch: Dispatch) }); }) .catch(error => { - console.log(error); + console.error(error); }); };