1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-11-27 18:58:08 +00:00

handle response codes

This commit is contained in:
slowbackspace 2019-03-04 19:03:07 +01:00
parent 5384bbdc02
commit 15cc6e00f3

View File

@ -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);
});
};