When I call the Ghash function, I get a promise I need to receive the result of this promise which is a hash, without that hash I cannot get the image I am looking for
async function Ghash(name){
let res = await fetch(`https://account.imperiomc.click/${name}.json?`+new Date().getTime()), json = await res.json(), hash, skin;
if (json.skins.slim != null){
hash = await json.skins.slim
skin = "Alex"
} else {
hash = await json.skins.default
skin = "Steve"
}
console.log("Skin model is "+skin)
return hash
}
function populateAuthAccounts(){
const authAccounts = ConfigManager.getAuthAccounts()
const authKeys = Object.keys(authAccounts)
if(authKeys.length === 0){
return
}
const selectedUUID = ConfigManager.getSelectedAccount().uuid
let authAccountStr = ''
authKeys.map((val) => {
const acc = authAccounts[val]
const hash = Ghash(acc.displayName)
const settingsCurrentAccounts = document.getElementById('settingsCurrentAccounts')
let url = `https://account.imperiomc.click/preview/hash/${hash}?`+new Date().getTime();
authAccountStr += `<div class="settingsAuthAccount" uuid="${acc.uuid}">
<div class="settingsAuthAccountLeft">
<img class="settingsAuthAccountImage" alt="${acc.displayName}" src="${url}">
</div>
<div class="settingsAuthAccountRight">
<div class="settingsAuthAccountDetails">
<div class="settingsAuthAccountDetailPane">
<div class="settingsAuthAccountDetailTitle">Usuario</div>
<div class="settingsAuthAccountDetailValue">${acc.displayName}</div>
</div>
<div class="settingsAuthAccountDetailPane">
<div class="settingsAuthAccountDetailTitle">UUID</div>
<div class="settingsAuthAccountDetailValue">${acc.uuid}</div>
</div>
</div>
<div class="settingsAuthAccountActions">
<button class="settingsAuthAccountSelect" ${selectedUUID === acc.uuid ? 'selected>Selected Account ✔' : '>Selecciona una cuenta'}</button>
<div class="settingsAuthAccountWrapper">
<button class="settingsAuthAccountLogOut">Cerrar sesión</button>
</div>
</div>
</div>
</div>`
settingsCurrentAccounts.innerHTML = authAccountStr
})
}
if I put all the content of authKeys.map((val) inside .then, for example (click me) the functions doesnt work with the buttons but the hash gives me the result I am looking for
i need to export the Ghash to hash (without any .then or async the code) that this is not related to Why is [...] instead of a value? if i do that, i have new issue, see the "if I put [...] inside .then..." moderators (dont close)
if anyone can tellme how i can fix it... I would be very grateful to you