UNPKG

ice.fo.utils

Version:

48 lines (40 loc) 1.06 kB
export default async function readSiteInfo({ store, $axios, $logger }) { const siteId = store.getters['ice/siteId']; if (!siteId) { $logger.error('[Read Site Info]', 'SiteId is empty.'); return siteId; } try { const { data } = await $axios.request({ url: '/svc/service/site', params: { id: siteId, }, cache: true, withCredentials: true, }); if (!data.item) { return; } store.commit('site/SET_SITE_INFO', data.item); const theme = store.getters['site/theme']; const { data: siteTheme } = await $axios.request({ url: '/svc/siteTheme/design', params: { theme: theme.name, }, cache: true, withCredentials: true, }); store.commit('site/SET_SITE_THEME', siteTheme.items[0]); } catch (e) { if (!e.message.includes('ECONNREFUSED')) { $logger.error( 'TokenUtils > Read Site Info', `"${siteId}" site does not exist`, 'Cannot connect to Backend Core', ); } } return siteId; }