diff --git a/lib/env-bundler.js b/lib/env-bundler.js index 079cb75..a17d84e 100644 --- a/lib/env-bundler.js +++ b/lib/env-bundler.js @@ -30,12 +30,12 @@ const ALL_TYPES = [ 'language', ]; -var coreBaseApi, componentManagerApi, clientId, clientSecret, apiUrlTable; +var coreBaseApi, componentManagerApi, clientId, clientSecret, apiUrlTable, defaultLang; const componentDetailExtractors = { page: (components) => components.map((c) => { - return { value: c.code, name: `${c.titles.en} (${c.code})` }; + return { value: c.code, name: `${c.titles[defaultLang]} (${c.code})` }; }), pageModel: (components) => components.map((c) => { @@ -865,6 +865,15 @@ const getToken = async function () { return res.data.access_token; }; +async function getDefaultLang() { + const response = await axios.get(apiUrlTable.language, { + withCredentials: true, + headers: { Authorization: `Bearer ${token}` }, + }); + + return response.data.payload.find(lang => lang.isDefault).code; +} + async function getComponents (type, componentsToFetch) { // Check if exists in cache if (hasProperty(componentCache, type)) { @@ -1223,7 +1232,7 @@ async function setupEnvironment (options) { token = await getToken(); - + defaultLang = await getDefaultLang(); } async function interactiveSession () {