* Load a JSON file via fetch. * @param {string} file Path of the file we want to load. * @returns {Promise } the translations in the specified file
(file)
| 8 | * @returns {Promise<object>} the translations in the specified file |
| 9 | */ |
| 10 | async function loadJSON (file) { |
| 11 | const baseHref = document.baseURI; |
| 12 | const url = new URL(file, baseHref); |
| 13 | |
| 14 | try { |
| 15 | const response = await fetch(url); |
| 16 | if (!response.ok) { |
| 17 | throw new Error(`Unexpected response status: ${response.status}`); |
| 18 | } |
| 19 | return await response.json(); |
| 20 | } catch { |
| 21 | Log.error(`Loading json file =${file} failed`); |
| 22 | return null; |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | return { |
| 27 | coreTranslations: {}, |
no outgoing calls
no test coverage detected