const Home = { init: async () => { let html = await fetch('/lib/pages/home/index.html').then((response) => response.text()); app.innerHTML = html; Home.house.setHTML(); Home.homestead.setHTML(); }, house: { loadAPI: async function () { let uuid = localStorage.getItem("uuid"); const URL = `${CONFIG.api}houses/list?mode=sheep`; return await fetch(URL, { method: 'GET', headers: { "Content-Type": "application/json", "Authorization": uuid } }).then((response) => response.json()); }, setHTML: async function () { let list = await Home.house.loadAPI(); list.sort((a, b) => b.id - a.id); console.log(list); let block_house = document.getElementById('home-personal-territory-list') for (let i = 0; i < list.length; i++) { const element = list[i]; block_house.innerHTML += `
Група №${element.group_id}

${element.title} ${element.number}

`; } } }, homestead: { loadAPI: async function () { let uuid = localStorage.getItem("uuid"); const URL = `${CONFIG.api}homestead/list?mode=sheep`; return await fetch(URL, { method: 'GET', headers: { "Content-Type": "application/json", "Authorization": uuid } }).then((response) => response.json()); }, setHTML: async function () { let list = await Home.homestead.loadAPI(); list.sort((a, b) => b.id - a.id); console.log(list); let block_homestead = document.getElementById('home-personal-territory-list') for (let i = 0; i < list.length; i++) { const element = list[i]; block_homestead.innerHTML += `
Група №${element.group_id}

${element.title} ${element.number}

`; } } } }