diff options
app - warn on fetch errors instead of spamming sentry
Diffstat (limited to 'ui')
-rw-r--r-- | ui/i18n-helper.js | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/ui/i18n-helper.js b/ui/i18n-helper.js index db2fd2dc4..3eee55ae9 100644 --- a/ui/i18n-helper.js +++ b/ui/i18n-helper.js @@ -25,18 +25,15 @@ const getMessage = (locale, key, substitutions) => { return phrase } -function fetchLocale (localeName) { - return new Promise((resolve, reject) => { - return fetch(`./_locales/${localeName}/messages.json`) - .then(response => response.json()) - .then( - locale => resolve(locale), - error => { - log.error(`failed to fetch ${localeName} locale because of ${error}`) - resolve({}) - } - ) - }) +async function fetchLocale (localeName) { + try { + const response = await fetch(`./_locales/${localeName}/messages.json`) + const locale = await response.json() + return locale + } catch (error) { + log.error(`failed to fetch ${localeName} locale because of ${error}`) + return {} + } } module.exports = { |